Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Can you please tell my why in the example below sub instanceof Super is false?
sub instanceof Super
false
function Super(){ var obj = { prop1: "value1" }; return obj; } var sub = new Super(); sub instanceof Super // false
Because its not an instance of that type - you've returned an anonymous object. If you would have written it like this:
function Super(){ this.prop1 = 'value1'; } var sub = new Super(); console.log(sub instanceof Super) // true
It would work as intended
Add a comment
Because its not an instance of that type
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.