mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-26 18:58:17 +00:00
Change 'operator' to 'method' (#2016)
I believe `.slice()` is an array prototype method, rather than an operator.
This commit is contained in:
committed by
Alexey Pyltsyn
parent
d05c83b7ab
commit
d3d7d55750
@@ -523,7 +523,7 @@ Note how in `handleClick`, we call `.slice()` to create a copy of the `squares`
|
||||
|
||||
### Why Immutability Is Important {#why-immutability-is-important}
|
||||
|
||||
In the previous code example, we suggested that you use the `.slice()` operator to create a copy of the `squares` array to modify instead of modifying the existing array. We'll now discuss immutability and why immutability is important to learn.
|
||||
In the previous code example, we suggested that you use the `.slice()` method to create a copy of the `squares` array to modify instead of modifying the existing array. We'll now discuss immutability and why immutability is important to learn.
|
||||
|
||||
There are generally two approaches to changing data. The first approach is to *mutate* the data by directly changing the data's values. The second approach is to replace the data with a new copy which has the desired changes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user