猿问
js原型链问题
var a = {}; a.prototype = {b:'heheh'} console.log(a.b)
为什么a.b 是undefined呢??
长风秋雁
浏览 540
回答 1
1回答
呼啦一阵风
这种情况其实是为 a 对象添加了一个 prototype 属性var a = {prototype:{b:'heheh'}};并不是对象的原型,我想你需要如此如此:var a = {b:"b”};var b= Object.create(a);b.b或者如此如此:function A(){} A.prototype = {b:'heheh'}var a = new A; a.b
0
0
0
随时随地看视频
慕课网APP
相关分类
JavaScript
我要回答