这里采用一个实例来说明:

 function Person(name) {
//以下都是Person的OwnProperty
this.name = name;
this.showMe = function () {
alert(this.name);
};
}
//每一个'类'都有prototype属性,而这里的protype指向的是一个prototype对象,所以这里的prototype不是OwnProperty
Person.prototype.from = function () {
alert("I come from prototype");
};
var father = new Person('js'); /*object.hasOwnProperty(proName);
判断proName的名称是不是object对象的一个属性或对象*/
alert(father.hasOwnProperty("name"));//true
alert(father.hasOwnProperty("from"));//false
alert(Person.prototype.hasOwnProperty("name"));//false
alert(Person.prototype.hasOwnProperty("from"));//true /*object1.isPrototypeOf(object2);
对象object1是否存在于另一个对象object2的原型链中*/
alert(Person.prototype.isPrototypeOf(father));//true
//【因为Person.prototype只有constructor,from,但father里有name,showMe之外还有constructor,from】

如如图所示:Person.prototype在father的原型链中

是不是很容易就理解了呢!~_~

深入解析hasOwnProperty与isPrototypeOf的更多相关文章

  1. js中的hasOwnProperty()和isPrototypeOf()

    js中的hasOwnProperty()和isPrototypeOf() 这两个属性都是Object.prototype所提供:Object.prototype.hasOwnProperty()和Ob ...

  2. hasOwnProperty与isPrototypeOf

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. typeof、instanceof、hasOwnProperty()、isPrototypeOf()

    typeof 操作符 instanceof 操作符 hasOwnProperty()方法 isPrototypeOf()方法 1.typeof 用于获取变量的类型,一般只返回以下几个值:string, ...

  4. js中的hasOwnProperty和isPrototypeOf方法

    hasOwnProperty:是用来判断一个对象是否有你给出名称的属性或对象.不过需要注意的是,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员. isPrototypeO ...

  5. javascript中的hasOwnProperty和isPrototypeOf

    hasOwnProperty:是用来判断一个对象是否有你给出名称的属性或对象.不过需要注意的是,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员.isPrototypeOf ...

  6. hasOwnProperty和isPrototypeOf方法使用

    hasOwnProperty():判断对象是否有某个特定的属性.必须用字符串指定该属性.(例如,o.hasOwnProperty("name"))  //复制自w3cschool ...

  7. (转)js中的hasOwnProperty和isPrototypeOf方法

    hasOwnProperty:是用来判断一个对象是否有你给出名称的属性或对象.不过需要注意的是,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员.isPrototypeOf ...

  8. 理解JAVASCRIPT 中hasOwnProperty()和isPrototypeOf的作用

    hasOwnProperty:是用来判断一个对象是否有你给出名称的属性或对象.不过需要注意的是,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员.格式如下: 1. 示例一: ...

  9. javascript 中isPrototypeOf 、hasOwnProperty、constructor、prototype等用法

    hasOwnProperty:是用来判断一个对象是否有你给出名称的属性或对象,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员. isPrototypeOf是用来判断要检查 ...

随机推荐

  1. KNN算法java实现代码注释

    K近邻算法思想非常简单,总结起来就是根据某种距离度量检测未知数据与已知数据的距离,统计其中距离最近的k个已知数据的类别,以多数投票的形式确定未知数据的类别. 一直想自己实现knn的java实现,但限于 ...

  2. CUDA学习资料分享(随时更新)

    1.Programming_Massively_Parallel_Processors.pdf 2.CUDA_C_Programming_Guide.pdf 3.CUDA范例精解通用GPU编程.pdf ...

  3. C# 调用Dll 传递字符串指针参(转)

    http://www.cnblogs.com/jxsoft/archive/2011/07/06/2099061.html

  4. 【OpenGL】入门

    根据OpenGL蓝宝书(OpenGL超级宝典)来入门,写的比较细,易懂,这里给我贴代码和记录零碎的事儿用 第一个代码 #include <gl/glut.h> void RenderSce ...

  5. 【创建本地仓库】【for Centos】CentOS下创建本地repository

    [日期]2014年4月24日 [平台]Centos 6.5 [工具]httpd yum-utils createrepo [步骤] 1)安装httpd. yum install httpd 2)安装y ...

  6. hdu 1437 天气情况【概率DP】

    天气情况 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  7. oracle表数据误删还原

    首先,找到数据删除前的一个时间点. select timestamp_to_scn(to_timestamp('2013-10-12 8:30:00', 'YYYY-MM-DD HH24:MI:SS' ...

  8. ThinkPHP中URL解析原理,以及URL路由使用教程!

    几个概念: THINKPHP 是一个MVC框架,使用PATHINFO解析出分组名,模块名,方法名,以及参数. PATHINFO:就是 http://localhost/index.php/Home/I ...

  9. Mac OS X 10.10优胜美地怎样完美接管iphone上的电话和短信

    自从今年苹果第一次的公布会上毛猫就特别注意这个功能.感觉特别Cool,特别方便.但直到今天毛猫才第一次成功測试出这个功能呀.尽管handoff功能还未測出来,可是认为在mac上发短信和打电话也已经足够 ...

  10. Codeforces Round #325 (Div. 2) A. Alena's Schedule 水题

    A. Alena's Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/pr ...