Are objects values?

Bruno Jouhier bjouhier at gmail.com
Sun Aug 20 12:41:33 UTC 2017


@T.J. Going back to your original post:

According to the definitions that I gave, objects are not values (they are
mutable) but they **have** a value.
Their value is their identity which is a memory handle (a reference) in
JavaScript.
Objects are **more** than their value; they are identity + state.
When you pass or assign an object, you pass/assign the identity. The state
is not copied.

The ES spec that you quote does not bluntly say that "objects are values";
it says that objects are *manipulated* as values.
I think that you can take the viewpoint that objects are not values, but
that they are manipulated through their identity, which is a value.

I did not discuss functions in my write-up (was saving this for a later
post that I never wrote)
but I would classify functions as values, conceptually.
This is an area where my model disagrees with JavaScript because functions
are mutable in JS: `(_ => {}).foo = 1;`.
But this is not the only disagreement: dates are values in my model and
objects in JS.

Bruno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170820/7746f155/attachment.html>


More information about the es-discuss mailing list