——proto—— 使用于使用函数和对象方法
let hd={
'name':'123',
}
hd.__proto__.show=function(){
console.log('show2')
}
console.log(hd)
hd.show()
![](https://img.haomeiwen.com/i16629650/9b8b07bbfab4fa49.png)
prototype 使用于 实列化函数方法
function hd(){
}
hd.prototype.show=function(){
console.log('show2')
}
const hfnew=new hd();
console.log(hfnew)
hfnew.show()
![](https://img.haomeiwen.com/i16629650/a3c0a487ffd73f1c.png)
网友评论