码迷,mamicode.com
首页 > Web开发 > 详细

js中的delete

时间:2015-10-09 01:56:11      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

delete删除的是构造函数中的属性,不能删除原型对象中的属性

function Foo(){}
    Foo.prototype.bar = 42;
    var foo = new Foo();
    delete foo.bar;
    alert(foo.bar);           // 42
    delete Foo.prototype.bar; // delete it from the prototype Object
    alert(foo.bar);           // undefined

 

js中的delete

标签:

原文地址:http://www.cnblogs.com/LittleBonnie/p/4862751.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!