| 1234567891011121314151617181920212223 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- function Person() {
- }
- Person.prototype.name = '我是图图';
- let p1 = new Person();
- p1.age = 10;
- console.log(p1);
- // in 在当前实例及原型上查找 找到 返回true;找不到 返回false
- // console.log("x" in p1);
- // hasOwnProperty 只检查实例自身 找到 返回true;找不到 返回false
- console.log(p1.hasOwnProperty("name"));
- </script>
- </body>
- </html>
|