“Spatenoperator Typscript” Code-Antworten

Spatenoperator Typscript

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

Spatenoperator Typscript

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

Spatenoperator Typscript

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

Ähnliche Antworten wie “Spatenoperator Typscript”

Fragen ähnlich wie “Spatenoperator Typscript”

Weitere verwandte Antworten zu “Spatenoperator Typscript” auf TypeScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen