Why does:
var a = "string";
console.log("length" in a);
Gives error
var b = new String("string");
console.log("length" in b);
Gives true.
a has property length just as same as b. a typeof is string but it's also an object with its own properties. MDN says:
JavaScript automatically converts primitives to String objects , so that it's possible to use String object methods for primitive strings.
What's wrong?