JavaScript prototype属性

function Hero(){

this.name="你好",

this.sayMe=function(){

alert("this is nihao") } }

Hero.prototype.name="hello";

Hero.prototype.sayMe=function(){

alert("this is hello") }

var hero =new Hero();


console.log(hero)    

console.log(hero.name)

console.log(hero.sayMe)

优先执行有变量名的,再执行__proto__


你可能感兴趣的:(JavaScript prototype属性)