首页 > Web开发 > 详细

js中的delete

时间:2015-10-09 01:54:30      阅读:219      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!