http://www.jb51.net/article/54247.htm

1,对象属性删除

1
2
3
4
5
6
7
8
9
10
11
12
13
function fun(){
 
this.name = 'mm';
 
}
 
var obj = new fun();
 
console.log(obj.name);//mm
 
delete obj.name;
 
console.log(obj.name); //undefined

2,变量删除

1
2
3
var name = 'lily';
delete name;
console.log(name); //lily

直接用delelte删除不了变量

3,删除不了原型链中的变量

1
2
3
fun.prototype.age = 18;
delete obj.age;
console.log(obj.age) //18
posted on 2016-10-09 16:43  HDU李少帅  阅读(160)  评论(0编辑  收藏  举报