如何打印出对象名"Student1“?使用Student1.constructor.name,我只能得到“学生”而不能得到"Student1“谢谢!
function Student(aName, aCourse, idNumber, noOfQuiz){
this.name = aName;
this.courseCode = aCourse;
this.studentID = idNumber;
}
var Student1 = new Student("David", "FD201F", "12345678")发布于 2021-04-01 00:27:38
您不能这样做,除非使用一些复杂的东西,例如尝试访问内存和检查与每个对象的实例相关的名称。使用某种类型的反射。但那将是一场噩梦
https://stackoverflow.com/questions/66891159
复制相似问题