84669 人が学習中
152542 人が学習中
20005 人が学習中
5487 人が学習中
7821 人が学習中
359900 人が学習中
3350 人が学習中
180660 人が学習中
48569 人が学習中
18603 人が学習中
40936 人が学習中
1549 人が学習中
1183 人が学習中
32909 人が学習中
如下代码,怎么使用call和apply实现people也可以用say方法,这里我用的是原型链__proto__实现的:
var human = { name:"xijinping", age:20, say:function(){ console.log("我是人类"); } } human.say(); var people = { __proto__:human, // human.call(this) 无效; } people.say();
走同样的路,发现不同的人生
原型继承应该用var people=object.create(human);你要用apply或者call那是类继承。
call 和 apply是用来指定上下文的。。
https://developer.mozilla.org... apply的MDN 您看过嘛 我觉得能解决你说的问题
原型继承应该用var people=object.create(human);你要用apply或者call那是类继承。
call 和 apply是用来指定上下文的。。
https://developer.mozilla.org... apply的MDN 您看过嘛 我觉得能解决你说的问题