@@ -99,19 +99,21 @@ of [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Glo
99
99
[ Map] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map ) , and
100
100
[ Set] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set ) .
101
101
102
- The only difference is that every method that would mutate the collection
103
- instead returns a new collection.
102
+ The difference for the immutable collections is that method which would mutate
103
+ the collection, like ` push ` , ` set ` , ` unshift ` or ` splice ` instead return a new
104
+ immutable collection. Methods which return new arrays like ` slice ` or ` concat `
105
+ instead return new immutable collections.
104
106
105
107
``` javascript
106
108
var vect1 = Immutable .Vector (1 , 2 );
107
109
var vect2 = vect1 .push (3 , 4 , 5 );
108
- var vect3 = vect2 .slice ( 1 , - 1 );
109
- var vect4 = vect1 .concat (vect2, vect3, vect4 );
110
+ var vect3 = vect2 .unshift ( 0 );
111
+ var vect4 = vect1 .concat (vect2, vect3);
110
112
assert (vect1 .length === 2 );
111
113
assert (vect2 .length === 5 );
112
- assert (vect3 .length === 3 );
113
- assert (vect4 .length === 10 );
114
- assert (vect4 .get (0 ) === 2 );
114
+ assert (vect3 .length === 6 );
115
+ assert (vect4 .length === 13 );
116
+ assert (vect4 .get (0 ) === 1 );
115
117
```
116
118
117
119
Almost all of the methods on ` Array ` will be found in similar form on
0 commit comments