const msg1 = {
fname:'Divyesh',
lname:'Patel',
}
const person = {
fullname : function(city,num)
{
return this.fname+ " " + this.lname+" "+ this.city +" "+ this.num ;
}
}
console.log(person.fullname.call(msg1,"Surat","972737"));
输出: Divyesh Patel未定义未定义
我在es6中编写了代码,并使用了调用方法,但未传递其他参数,显示未定义
答案 0 :(得分:0)
const msg1 = {
fname: 'Divyesh',
lname: 'Patel',
}
const person = {
fullname: function (city, num) {
return this.fname + " " + this.lname + " " + city + " " + num;
}
}
console.log(person.fullname.call(msg1, "Surat", "972737"));