What is Spread Operator in ES6?

devquora
devquora

Posted On: Feb 22, 2018

 

Spread Operator provides a new way to manipulate array and objects in Es6.A Spread operator is represented by … followed by the variable name.

Example :

let a =[7,8,9];
let b=[1,2,3,...a,10];
console.log(b); // [1,2,3,7,8,9,10]

So spread operator spreads the contents of variable a and concatenates it in b.

Another Example

function print(...z){
	console.log(z); 
}

print(1,2,3,4);//[1,2,3,4]

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    ES6 Interview Questions

    What is ES6?

    Es6 or ECMASCRIPT 2015 is sixth major release of ECMAScript language which comes with a lot of new features and syntax..

    ES6 Interview Questions

    List some new features of ES6

    New Features in ES6. Support for constants (also known as “immutable variables”) Block-Scope support for both varia..

    ES6 Interview Questions

    What is Babel?

    Babel is one of the most popular JavaScript transpilers and becomes the industry standard. It allows us to write ES6 cod..