constructor

Custom type => `instancof` Primitive type => `typeof` typeof num1, num2의 타입이 다르게 출력된다. num2를 생성자 new를 통해 생성했기 때문이다. const actionTypes = ['play','connect', 'disconnect', 'cancel']; const userId = undefined; console.log(typeof actionTypes); //object console.log(typeof userId); // undefined console.log(typeof undefined); // undefined console.log(typeof null); // object constructor 인스턴스의 '프로토타입'의 참조..
긴 말 필요없이 소스코드를 보자. 생성자 Student 선언 생성자 호출 instanceof 메소드 instanceof 메소드 [구문] object_name instanceof Constructor_name(==Class_name) ※ Return type is Boolean (true or false) [용도] Object의 Prototype 혹은 Constructor 이름이 맞는지 확인 생성자의 prototype 속성이 객체의 프로토타입 체인에 존재하는지 판별. https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/instanceof [다음편] 프로토타입에 대해 아라보자. https://m-falcon.tistory.com/..
M_Falcon
'constructor' 태그의 글 목록