News for hackers. Stuff that matters.
Re:Eloquent JavaScript 3rd Edition (2018) by galaxyLogic on Tuesday April 28, 2020 @12:10AM (#23003270)
> This implicitly makes all methods in an Object that depend on or modify an Object's internal state impure functions

Note that you can have methods which do not depend on mutable state. In ES6 you can FREEZE objects, which you could do in the constructor. Freeze the object after having set its "instance variables". Now all methods of that object are "pure functions". So you can choose. Choose to create pure functions or impure.

Creating a new immutable instance really is equivalent to creating a set of immutable ('pure' if you like) functions.

There are no comments on this comment yet.