js delete删除对象属性,delete删除不了变量及原型链中的变量
js delete删除对象属性,delete删除不了变量及原型链中的变量
一、delete删除对象属性
function fun(){ this.name = 'gg'; } var obj = new fun(); console.log(obj.name);//gg delete obj.name; console.log(obj.name); //undefined
二、delete删除不了变量
var name = 'gg'; delete name; console.log(name); //gg
三、delete删除不了原型链的变量
fun.prototype.age = 11; delete obj.age; console.log(obj.age) //11