Clarification of array example

pull/2491/head^2
Pier Bover 7 years ago committed by GitHub
parent bda6aff09c
commit 0813b4645b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,8 +7,8 @@ Because Svelte's reactivity is triggered by assignments, using array methods lik
One way to fix that is to add an assignment that would otherwise be redundant:
```js
function addNumber() {
numbers.push(numbers.length + 1);
function addNumber(value) {
numbers.push(value);
numbers = numbers;
}
```
@ -16,8 +16,8 @@ function addNumber() {
But there's a more *idiomatic* solution:
```js
function addNumber() {
numbers = [...numbers, numbers.length + 1];
function addNumber(value) {
numbers = [...numbers, value];
}
```

Loading…
Cancel
Save