3 ms·
> 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 n
by galaxyLogic 7y ago
> 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.