本文主要是介绍Javascript constructor prototype __proto__,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
function Func(){}// 首字母大写
Func.__proto__ === Function.prototype;
Function.__proto__ === Function.prototype;
Object.__proto__ === Function.prototype;Func.constructor === Function;
Function.constructor === Function;
Object.constructor === Function;// 函数也是对象
Func.prototype.__proto__ === Object.prototype;
Function.prototype.__proto__ === Object.prototype;// Object.prototype 是老大 不是任何其他东东的实例
Object.prototype.__proto__ === null;var myFunc = new Func();
myFunc.__proto__ === Func.prototype
myFunc.constructor === Func;
myFunc.prototype === undefined;var obj = {}
obj.__proto__ === Object.prototype;
obj.constructor === Object;
obj.prototype === undefined;var obj2 = new Object();
obj2.__proto__ === Object.prototype;
obj2.constructor === Object;
obj2.prototype === undefined;var func2 = new Function();
func2.__proto__ === Function.prototype;
func2.constructor === Function;
func2.prototype.__proto__ === Object.prototype;
// js 是prototype 继承 class 只是语法糖
这篇关于Javascript constructor prototype __proto__的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!