In JavaScript why does the second line below return undefined
and not an error?
var apple = 'apple';
apple.colour; //undefined
An expression that evaluates to a primitive value that appears on the left side of a .
or []
operator will be automatically "wrapped" in an object of the appropriate type (String, Number, Boolean).
Thus
"hello".length
is evaluated as if it were
new String("hello").length
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments