소소한 JS 팁(2)
재미로 풀어본 JS quiz 사이트인데 소소하게 팁들을 알게되어 정리해본다!
https://javascriptquiz.com/?fbclid=IwAR31L9U2qjkB_krPoQtn2R_F6RShcez6-hZzwmf8rdTHWmaOmGQJEkaUdrw
📓 Quiz 2
1 | console.log("This is a string." instanceof String); |
📝 A: false
instanceof
연산자는 생성자의prototype
속성이 객체의 프로토타입 체인 어딘가 존재하는지 판별오브젝트 리터럴 노테이션으로 생성된 오브젝트는 예외적
1
2
3
4
5const simpleStr = "This is a simple string";
const myString = new String();
simpleStr instanceof String; // returns false, prototype chain을 확인하고, undefined를 찾는다.
myString instanceof String; // returns true