Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccuracy in the "Constants" section #55

Open
Retsam opened this issue Jul 23, 2016 · 3 comments
Open

Inaccuracy in the "Constants" section #55

Retsam opened this issue Jul 23, 2016 · 3 comments

Comments

@Retsam
Copy link

Retsam commented Jul 23, 2016

From the section on constants:

With the above two constants the following expression will always return true.

john.age + five === ({name: 'John', age: 30}).age + (5)

This above statement isn't true; while john is declared as a constant; that only means that john can't be replaced with a different object, not that its fields can't be modified. A simple john.age = 10 would cause the above expression to return false, despite the definition of john as a constant.

@jethrolarson
Copy link
Collaborator

Yeah there's definitely common confusion about const not making objects immutable. This section should probably distinguish between them

@joe-strummer
Copy link

Yeah just came here to say that - a more straightforward example could just be to have const five and const six for instance.

@dead-claudia
Copy link
Contributor

dead-claudia commented Aug 11, 2016

I think it could be fixed by saying it's referentially transparent for non-symbol primitives, the result of calling Symbol.for("global-symbol"), and the result of calling any pure function that only returns one of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants