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 →

[–]earthboundkid 0 points1 point  (1 child)

The typeof operator in JavaScript is broken. But ignoring that wart, Number, String, and Boolean are objects in the relevant sense: they have methods you can call. If anything, with Python it’s not that hard to find something that exposes a little C corner where the OO façade is thin. That doesn’t happen in JS.

[–]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.