Backbencher.dev

Spread Operator in JavaScript

Last updated on 11 Feb, 2021

Object Spread ES9

Spread operator(...) copies own enumerable properties of an object to a new object.

const obj = { name: "Backbencher", topic: "JavaScript" };
const objCopy = { ...obj };
console.log(objCopy);
/* OUTPUT:
{
  name: "Backbencher",
  topic: "JavaScript"
}
*/
--- ○ ---
Joby Joseph
Web Architect