- 已关闭。**此问题为not reproducible or was caused by typos。当前不接受答案。
这个问题是由打字错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
13小时前关门了。
Improve this question
这是我想自己编的代码,但是调用不起作用
let course = {
name: "",
description: "",
students: [],
addStudents(studentName) {
this.students.push(studentName);
console.log(`${studentName} added to ${this.name}course`);
},
date: "12/12/2021",
};
let english = {
name: "english course",
description: "this is good course",
students: [],
};
let math = {
name: "math course",
description: "this is very good course",
students: [],
};
let addStudents = math.addStudents;
addStudents.call(english, "Enoh");
addStudents.call(math, "Daniel");
addStudents.call(english, "Ellias");
addStudents.call(math, "Rafael");
console.log(math);
console.log(english);
这是我想自己编的代码,但是调用不起作用
1条答案
按热度按时间yhxst69z1#
您指的是
course.addStudents
而不是math.addStudents
,控制台中出现读取错误