“SPADE Operator TypeScript” Kode Jawaban

SPADE Operator TypeScript

let origObjectOne = {a: 1, b: 2, c: 3};                 //{a: 1, b: 2, c: 3}
let origObjectTwo = {d: 4, e: 5, f: 6};                 //{d: 4, e: 5, f: 6}
 
//Create new object from existing object
let copyObject = {...origObjectOne};                        //{a: 1, b: 2, c: 3}
 
//Create new object from existing object + more elements
let newObject = {...origObjectOne, g: 7, h: 8};             //{a: 1, b: 2, c: 3, g: 7, h: 8}
 
//Create object by merging two objects
let mergedObject = {...origObjectOne, ...origObjectTwo};    //{a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}
Inquisitive Ibex

SPADE Operator TypeScript

let origArrayOne = [ 1, 2, 3];                          //1,2,3
let origArrayTwo = [ 4, 5, 6];                          //4,5,6
 
//Create new array from existing array
let copyArray = [...origArrayOne];                      //1,2,3
 
//Create new array from existing array + more elements
let newArray = [...origArrayOne, 7, 8];             //1,2,3,7,8 
 
//Create array by merging two arrays
let mergedArray = [...origArrayOne, ...origArrayTwo];   //1,2,3,4,5,6
Inquisitive Ibex

SPADE Operator TypeScript

function myFunction(x, y, z) { 
    console.log( x );
    console.log( y );
    console.log( z );
}
 
var parametersArray = [0, 1, 2];
 
myFunction(...parametersArray);     //0, 1, 2
Inquisitive Ibex

Jawaban yang mirip dengan “SPADE Operator TypeScript”

Pertanyaan yang mirip dengan “SPADE Operator TypeScript”

Lebih banyak jawaban terkait untuk “SPADE Operator TypeScript” di TypeScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya