수업 내에서 개체를 찾으려면 어떻게합니까? 클라이언트 코드에서클래스 내에서 개체를 찾으십시오.
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");
사용자 목록이있는 클래스를 만들어야합니다. – giammin
나는이 질문을 정말로 이해하지 못합니다. "두 대상을 찾는다"는 것은 무엇을 의미합니까? 이전에받은 인수를 사용하여 기존 인스턴스를 반환하도록 생성자를 효과적으로 메모 하시겠습니까? –
클라이언트가 생성 한 사용자 개체를 추적하는 방법이 있습니까? 그리고 사용자 목록에 대한 권장 사항도 있습니다. – Rod