亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - js question, please answer
PHPz
PHPz 2017-05-19 10:34:49
0
1
711
function Animal() {};
function Cat() {};
function Dog() { return new Animal};
Cat.prototype = new Animal;
console.log(new Dog instanceof Animal);//true為什么?
console.log(new Dog instanceof Dog);//false 為什么?
console.log(new Cat instanceof Animal);//true
PHPz
PHPz

學(xué)習(xí)是最好的投資!

reply all(1)
Peter_Zhu

If the constructor returns an "object", then this object will replace the entire new result. If the constructor does not return an object, the constructor will return this by default, which is the Dog.一般構(gòu)造函數(shù)不返回值的。function Dog() { return new Animal};new Dog()等同于創(chuàng)建了 Animal instance. I don’t know if my analysis is correct or not. Comments are welcome.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template