instanceof原理  照慣 " /> 午夜精品福利电影,久久aⅴ国产欧美74aaa,亚洲高清不卡

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

理解Javascript_07_理解instanceof實現原理

  在《Javascript類型檢測》一文中講到了用instanceof來用做檢測類型,讓我們來回顧一下:

   那么instanceof的這種行為到底是如何實現的呢,現在讓我們揭開instanceof背后的迷霧。

  instanceof原理

  照慣例,我們先來看一段代碼:

function Cat(){}Cat.prototype = {}function Dog(){}Dog.prototype ={}var dog1 = new Dog();alert(dog1 instanceof Dog);//truealert(dog1 instanceof Object);//trueDog.prototype = Cat.prototype;alert(dog1 instanceof Dog);//falsealert(dog1 instanceof Cat);//falsealert(dog1 instanceof Object);//true;var  dog2= new Dog();alert(dog2 instanceof Dog);//truealert(dog2 instanceof Cat);//truealert(dog2 instanceof Object);//trueDog.prototype = null;var dog3 = new Dog();alert(dog3 instanceof Cat);//falsealert(dog3 instanceof Object);//truealert(dog3 instanceof Dog);//error 

it知識庫理解Javascript_07_理解instanceof實現原理,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 乌恰县| 凤台县| 海南省| 盈江县| 瓦房店市| 江源县| 津市市| 永善县| 铜鼓县| 鞍山市| 屏东市| 盐池县| 双牌县| 西盟| 自治县| 永宁县| 当涂县| 商都县| 彩票| 青田县| 镇赉县| 荔浦县| 盘锦市| 卓尼县| 普兰县| 瑞金市| 桂平市| 西充县| 昭苏县| 洛隆县| 五台县| 林甸县| 前郭尔| 广河县| 灌阳县| 策勒县| 商丘市| 芒康县| 林口县| 博爱县| 潮州市|