编程语言
首页 > 编程语言> > JavaScript 原型以及原型链。

JavaScript 原型以及原型链。

作者:互联网

1. 属性介绍

var arr = [];
var obj = {};
var set = new Set();
var map = new Map();
var sym = Symbol();
var fn = function () {};
var date = new Date();
var reg = /\d+/;
var err = new Error();
var int = new Int8Array();
var float = new Float32Array();
var bool = true;

console.log(arr.__proto__, `arr.__proto__`);
console.log(arr.__proto__ === Array.prototype, `arr.__proto__ === Array.prototype`);
console.log(obj.__proto__, `obj.__proto__`);
console.log(obj.__proto__ === Object.prototype, `obj.__proto__ === Object.prototype`);
console.log(set.__proto__, `set.__proto__`);
console.log(set.__proto__ === Set.prototype, `set.__proto__ === Set.prototype`);
console.log(map.__proto__, `map.__proto__`);
console.log(map.__proto__ === Map.prototype, `map.__proto__ === Map.prototype`);
console.log(sym.__proto__, `sym.__proto__`);
console.log(sym.__proto__ === Symbol.prototype, `sym.__proto__ === Symbol.prototype`);
console.log(fn.__proto__, `fn.__proto__`);
console.log(fn.__proto__ === Function.prototype, `fn.__proto__ === Function.prototype`);
console.log(date.__proto__, `date.__proto__`);
console.log(date.__proto__ === Date.prototype, `date.__proto__ === Date.prototype`);
console.log(reg.__proto__, `reg.__proto__`);
console.log(reg.__proto__ === RegExp.prototype, `reg.__proto__ === RegExp.prototype`);
console.log(err.__proto__, `err.__proto__`);
console.log(err.__proto__ === Error.prototype, `err.__proto__ === Error.prototype`);
console.log(int.__proto__, `int.__proto__`);
console.log(int.__proto__ === Int8Array.prototype, `int.__proto__ === Int8Array.prototype`);
console.log(float.__proto__, `float.__proto__`);
console.log(float.__proto__ === Float32Array.prototype, `float.__proto__ === Float32Array.prototype`);
console.log(bool.__proto__, `bool.__proto__`);
console.log(bool.__proto__ === Boolean.prototype, `bool.__proto__ === Boolean.prototype`);

image

var num = 1;
var str = '1';
var arr = [];
var obj = {};
var set = new Set();
var map = new Map();
var sym = Symbol();
var fn = function () {};
var date = new Date();
var reg = /\d+/;
var err = new Error();
var int = new Int8Array();
var float = new Float32Array();
var bool = true;

console.log(num.constructor, `num.constructor`);
console.log(str.constructor, `str.constructor`);
console.log(arr.constructor, `arr.constructor`);
console.log(obj.constructor, `obj.constructor`);
console.log(set.constructor, `set.constructor`);
console.log(map.constructor, `map.constructor`);
console.log(sym.constructor, `sym.constructor`);
console.log(fn.constructor, `fn.constructor`);
console.log(date.constructor, `date.constructor`);
console.log(reg.constructor, `reg.constructor`);
console.log(err.constructor, `err.constructor`);
console.log(int.constructor, `int.constructor`);
console.log(float.constructor, `float.constructor`);
console.log(bool.constructor, `bool.constructor`);

image

var arr = [];
var obj = {};
var set = new Set();
var map = new Map();
var sym = Symbol();
var fn = function () {};
var date = new Date();
var reg = /\d+/;
var err = new Error();
var int = new Int8Array();
var float = new Float32Array();
var bool = true;

console.log(arr.prototype, `arr.prototype`);
console.log(obj.prototype, `obj.prototype`);
console.log(set.prototype, `set.prototype`);
console.log(map.prototype, `map.prototype`);
console.log(sym.prototype, `sym.prototype`);
console.log(fn.prototype, `fn.prototype`);
console.log(date.prototype, `date.prototype`);
console.log(reg.prototype, `reg.prototype`);
console.log(err.prototype, `err.prototype`);
console.log(int.prototype, `int.prototype`);
console.log(float.prototype, `float.prototype`);
console.log(bool.prototype, `bool.prototype`);

image

标签:__,.__,console,log,以及,proto,JavaScript,原型,prototype
来源: https://www.cnblogs.com/jwyblogs/p/16300232.html