阅读背景:

[Javascript] Avoiding Mutations in JavaScript with Immutable Data Structures

来源:互联网 

To demonstrate the difference between mutability and immutability, imagine taking a drink from a glass of water. If our glass is mutable, when we take a drink, we retain the same glass and change the amount of water in that glass. However, if our glass is immutable, when we take a drink, we get back a brand new, identical glass containing the correctly drank amount. Perhaps a strange way to conceive of the action, but creating new data structures makes our methods pure and thread-safe, a benefit of functional programming.To demonstrate the difference between mutabilit




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: