function Person() {}
Person. prototype. friend =[];
Person. prototype. name = ”;
// var a = new Person() ;
// a. friend[0]=’王琦’;
// a. name = ‘程娇’;
// var b = new Person ();
// b. friend?
// b. name?
1、 创建一个空对象,并且this变量引用该对象,同时还继承了该函数的原型。
2、 属性和方法被加入到this引用的对象中。
3、 新创建的对象由this所引用,并且最后隐式的返回this 。

Was this helpful?

0 / 0

发表回复 0

Your email address will not be published.