I\'m trying to understand how JavaScript\'s prototype-based inheritance works. I was expecting the below outputs would evaluate as true. Why is this?
true
This is because the string primitives are not string objects. If you want the above code to work, the string should be constructed via the String class, as in:
String
var myStr = new String("Sample"); String.prototype.isPrototypeOf(myStr); // true