Quick actions

cmd+k|ctrl+k

Navigation

Languages

Spreads Operators with Arrays

Snippet info

Language

JavaScript

Visibility

public

Author

sanjivrai543

Created

2020-10-26T22:35:13Z

Updated

2020-10-26T22:37:03Z

//String to array all kind of transformation to arrays can be performed by isong Spread Operators with arrays
const arrayOne=['Maria','Anna','Alex'];
const arrayTwo=['Said','Ismail','Aisha'];

//extract the values from both the arrays 
//concating two arrays 
const concatArray=[...arrayOne,...arrayTwo];

concatArray.forEach(function(name){console.log(name);});

const name='Marain';
const nameToArray=[...name];
nameToArray.forEach(function(letter){console.log(letter);})
const addNumber= function(n1,n2,n3){return n1+n2+n3;}
const numbers=[1,5,6,7,4,21,3];
console.log(addNumber(numbers[0],numbers[1],numbers[2]));
const addition=addNumber(...numbers);
console.log(addition);
INFO