functional-programming-jargon
functional-programming-jargon copied to clipboard
Inaccuracy in the "Constants" section
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.
Yeah there's definitely common confusion about const not making objects immutable. This section should probably distinguish between them
Yeah just came here to say that - a more straightforward example could just be to have const five
and const six
for instance.
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.