
Understanding JavaScript Core Concepts: Spread Operator, Constructor Functions, and Built-in Objects
Spread Operator in JavaScript Before technical part of spread operator we shall understand the spread operator by non technically Imagine you have a bag of candies 🍬. Inside the bag there are 3 candies: [🍬, 🍬, 🍬] Now you want to pour all the candies out on the table. When you open the bag and spread the candies on the table, that is like the Spread Operator (...) in JavaScript. Simple Example You have a box: box1 = [ 1 , 2 , 3 ] Now you open the box and spread everything into another box let box1 = [ 1 , 2 , 3 ]; let box2 = [... box1 ]; Now box2 also has the same toys. box2 = [ 1 , 2 , 3 ] Simple Meaning Spread Operator (...) = Open a box and spread everything inside it. Now lets deep dive into the technical part of spread operator What is Spread Operator? The Spread Operator (...) is used to expand (spread) the elements of an iterable (like an array or string) or the properties of an object into individual elements. It was introduced in ES6 (ECMAScript 2015) and is commonly used for c
Continue reading on Dev.to
Opens in a new tab




