首页 新闻 会员 周边

为啥输出undefined

0
[已解决问题] 解决于 2019-04-13 18:37

function ba(name,age){
this.name=name;
this.eat=function(){
console.log(this.nanme+": eat");
this.jump=function(){
console.log(this.name+":ump: "+this.age);
}
}
}
function son(){}
var s =new son();
son.name="xao";
son.age=123;
console.log(ba.call(son));

fangpengcheng_方鹏程的主页 fangpengcheng_方鹏程 | 初学一级 | 园豆:4
提问于:2019-04-10 17:12

建议用代码块整理一下代码,看着不舒服。

hellotim 5年前

@hellotim: 好的大佬

xiaofang.bk 5年前
< >
分享
最佳答案
0

ba 没有返回值,再ba方法中添加return this,可以输出son方法。

奖励园豆:5
ohyex | 小虾三级 |园豆:1496 | 2019-04-10 18:20

大佬能不能解释下,不是son调用ba中的方法吗,但ba有两个方法,不知道调用哪个,但不管哪个,都有console.log啊,应该有打印啊

fangpengcheng_方鹏程 | 园豆:4 (初学一级) | 2019-04-11 06:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册