如何从我的班级中找到一个对象?
这是我的独立 JavaScript 组件:
function User(first, last){
if (this instanceof User){
this.name = first + " " + last;
//Is there a way here to find either User objects here? (John or Jane)
//How would I changed to the desired User object and start working with it?
}
else return new User(first, last);
}
在客户端代码中,我有以下内容:
User("John", "Smith");
User("Jane", "Doe");