spade operator typescript

Solutions on MaxInterview for spade operator typescript by the best coders in the world

showing results for - "spade operator typescript"
Isabel
11 Jun 2018
1function myFunction(x, y, z) { 
2    console.log( x );
3    console.log( y );
4    console.log( z );
5}
6 
7var parametersArray = [0, 1, 2];
8 
9myFunction(...parametersArray);     //0, 1, 2
10
Thiago
17 Jul 2020
1let origArrayOne = [ 1, 2, 3];                          //1,2,3
2let origArrayTwo = [ 4, 5, 6];                          //4,5,6
3 
4//Create new array from existing array
5let copyArray = [...origArrayOne];                      //1,2,3
6 
7//Create new array from existing array + more elements
8let newArray = [...origArrayOne, 7, 8];             //1,2,3,7,8 
9 
10//Create array by merging two arrays
11let mergedArray = [...origArrayOne, ...origArrayTwo];   //1,2,3,4,5,6
12
Matisse
17 Jan 2021
1let origObjectOne = {a: 1, b: 2, c: 3};                 //{a: 1, b: 2, c: 3}
2let origObjectTwo = {d: 4, e: 5, f: 6};                 //{d: 4, e: 5, f: 6}
3 
4//Create new object from existing object
5let copyObject = {...origObjectOne};                        //{a: 1, b: 2, c: 3}
6 
7//Create new object from existing object + more elements
8let newObject = {...origObjectOne, g: 7, h: 8};             //{a: 1, b: 2, c: 3, g: 7, h: 8}
9 
10//Create object by merging two objects
11let mergedObject = {...origObjectOne, ...origObjectTwo};    //{a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}
12
similar questions
queries leading to this page
spade operator typescript