function Person() {
this.firstName;
this.lastName;
this.age;
this.eyeColor;
this.nationality;
}
var luffy = new Person();
luffy.firstName="Monkey";
console.log(luffy);
在此,如果我在控制台中打开,它将显示一个名字,但是我在哪里可以看到这个对象的主体,我的意思是我在哪里可以看到这个对象原型(prototype)中的内容...因为我们可以看到构造函数如果我们打开对象原型(prototype),我想以同样的方式查看该对象父对象的主体...请帮助我(我没有在原型(prototype)中给出任何内容作为参数,即人)
最佳答案
使用> luffy.constructor
它将返回构造函数定义。
使用> luffy.__proto__
来了解对象的原型(prototype)。
function Person() {
this.firstName;
this.lastName;
this.age;
this.eyeColor;
this.nationality;
}
var luffy = new Person();
luffy.firstName="Monkey";
console.log(luffy.constructor); // returns the constructor i.e., is the definition of the function contructor
关于javascript - 如何在控制台 javascript 中查看原型(prototype)主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44492522/