js如何判断属性是本身具有还是继承别人的

快乐打工仔 分类:实例代码

本章节介绍一下如何属性是本身自有的还是继承别人的,下面就通过代码实例做一下介绍。

代码实例:

function Antzone(){
  this.webName="前端教程网";
  this.url="pipipi.net"
}
Antzone.prototype={
  age:3
}
var antzone=new Antzone();
console.log(antzone.hasOwnProperty("webName"));
console.log(antzone.hasOwnProperty("age"));

代码比较简单,更多内容可以参阅js hasOwnProperty()一章节。

回复

我来回复
  • 暂无回复内容