Object Literals and Spread Operator

Arek Jaworski
2 min readAug 14, 2018

In this tutorial we will learn how to take advantage of spread operator in order to initialise a new object with optional properties.

Let’s start from a very basic example. We can create a new object with following key-value notation:

const object = {
a: 'foo',
b: 123,
c: { obj: 'bar' }
};

--

--

Arek Jaworski

Software Architect — AWS/Node.JS/JavaScript Contractor and Tutor. I write about programming, computer science, algorithms and more!