12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <!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>
- let arr = [1, 2, 3];
- // Array 构造函数 构造函数类似于工厂可以源源不断的生产数组
- // arr2 是数组的实例化对象
- // 可以通过构造函数实例化很多的数组对象
- let arr2 = new Array(1, 2, 3);
- console.log(arr);
- console.log(arr2);
- // constructor 找到自己的构造函数
- console.log(arr.constructor);
- console.log(arr2.constructor);
- // 原型 prototype
- // 数组原型
- // console.log(Array.prototype);
- // // 字符串原型
- // console.log(String.prototype);
- // // 数字原型
- // console.log(Number.prototype);
- // // 布尔值原型
- // console.log(Boolean.prototype);
- // // 函数原型
- // console.log(Function.prototype);
- // 在数组原型上新增方法
- // Array.prototype.loveCoding = function () {
- // console.log("我很喜欢编码");
- // }
- // arr.loveCoding();
- // 实例化 的对象 上的原型 __proto__
- console.log(arr.__proto__);
- </script>
- </body>
- </html>
|