注:本文章是本人看文档的笔记,勿喷~~



所以,并根据delete 返回的结果来判断对象是否有这个属性,也不能判断对象的这个属性是否删除成功。

var obj={p:1};
'p' in obj; //true
'a' in obj; //false
toString in obj; //false
'toString' in obj; //true
用in判断对象是否存在属性时,属性名一定要打引号,否则即使存在这个属性,也会返回false。







注:本文章是本人看文档的笔记,勿喷~~
所以,并根据delete 返回的结果来判断对象是否有这个属性,也不能判断对象的这个属性是否删除成功。
var obj={p:1};
'p' in obj; //true
'a' in obj; //false
toString in obj; //false
'toString' in obj; //true
用in判断对象是否存在属性时,属性名一定要打引号,否则即使存在这个属性,也会返回false。
本文标题:2019-02-18 对象[es5]
本文链接:https://www.haomeiwen.com/subject/qjsaeqtx.html
网友评论