您当前的位置: 首页 > 

暂无认证

  • 3浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

hasOwnProperty

发布时间:2020-09-11 19:35:37 ,浏览量:3

<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script type="text/javascript"> class Person { name=null; age=0; } Person.prototype.height=0; /*let p=new Person();
	// in的特点: 只要类中或者原型对象中有, 就会返回true
	console.log("name" in p);
	console.log("width" in p); // false
    console.log("height" in p); // true
    */ // 需求: 判断某一个对象自身是否拥有某一个属性 let p = new Person(); // 特点: 只会去类中查找有没有, 不会去原型对象中查找 console.log(p.hasOwnProperty("name")); console.log(p.hasOwnProperty("height")); </script> </body> </html> 
关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.0746s