自身属性和原型属性
想问两个结果输出的为什么不一样。
function foo(){} foo.prototype.z = 5; var obj = new foo(); obj.z = 7; console.log(obj.z); //输出7 delete obj.z; console.log(obj.z);//输出5
function foo(){ this.z = 5; } var obj = new foo(); obj.z = 7; console.log(obj.z); //输出7 delete obj.z; console.log(obj.z);//输出undefined