JavaScript prototype属性

2021-03-17  本文已影响0人  歌声缓缓

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__
上一篇下一篇

猜你喜欢

热点阅读