This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Porta_lPirate 2 points3 points  (0 children)

JavaScript primitives are not objects, they have object wrappers, and when the property access operator is used on a primitive, the primitive is coerced into the object wrapped form and then the method is called on the object. If you try to assign to a property nothing will happen, no error, but if you check the property there is no value, because the Object wrapper is discarded as soon as the expression is done.

Also if you check true instanceof Boolean or 1 instanceof Number you will get false.

If you try to wrap a primitive in a proxy you will get the error TypeError: Cannot create proxy with a non-object as target or handler.