Skip to content

Commit 8ea21c8

Browse files
SketchBookkeepermichalsnik
authored andcommitted
Update no-side-effects-in-computed-properties.md (#480)
Provide more details on working with arrays inside computed properties.
1 parent 88b1f2d commit 8ea21c8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/rules/no-side-effects-in-computed-properties.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ computed: {
1616
return `${this.firstName} ${this.lastName}`
1717
},
1818
reversedArray () {
19-
return this.array.reverse() // <- side effect
19+
return this.array.reverse() // <- side effect - orginal array is being mutated
2020
}
2121
}
2222
```
@@ -29,7 +29,7 @@ computed: {
2929
return `${this.firstName} ${this.lastName}`
3030
},
3131
reversedArray () {
32-
return this.array.slice(0).reverse()
32+
return this.array.slice(0).reverse() // .slice makes a copy of the array, instead of mutating the orginal
3333
}
3434
}
3535
```

0 commit comments

Comments
 (0)