This repository showcasing typescript spread operators usages possibilities in different scenarios.

Spread Operator Usages

Copy array

Copying one array of data to another is possible by simply spreading the array to be copied.

const a = [1, 2, 3, 4];
const b = [...a];
console.log("B (copied from a): ", b);
// Output: B (copied from a): [ 1, 2, 3, 4 ]

Copy Object

One can copy an object in a similar way as a copy of an array by providing an object in object braces.

const obj1 = {x: 10, y: 20};

// Provide the same properties names while destructuring object
const obj2 =…

Sunil Pandey

Front End Developer at IONGroup

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store