Hey developers! If you are eager to learn various operators and syntax in JavaScript, then give this article a read. In this article, we are going to see what is spread operator in JavaScript is and how to apply it.
The spread operator comes with the ES6 bundle and brings tons of convenience for us developers. Essentially, a spread operator literally spreads out the list of objects. Let’s have a look at how exactly it is used.
Example 1: Basic Use of Spread Operator in JavaScript
list_number = [1, 2, 3, 4, 5]
console.log( ...list_number )
// OUTPUT: 1 2 3 4 5
Example 2: Combine Multiple Lists Using Spread Operator
list_number = [1, 2, 3, 4, 5]
list_alpha = ['apple', 'banana', 'cat', 'dog', 'elephant']
console.log( [ ...list_number, ... list_alpha ] )
// OUTPUT: [1, 2, 3, 4, 5, 'apple', 'banana', 'cat', 'dog', 'elephant']
Example 3: Inserting 1 list into Another Using Spread Operator
list_number = [1, 2, 3, 4, 5]
list_alpha = ['apple', 'banana', ...list_number, 'cat', 'dog', 'elephant']
console.log( list_alpha )
// OUTPUT: apple banana 1 2 3 4 5 cat dog elephant
Example 4: Passing into Functions Using Spread Operator
list_number = [1, 2, 3, 4, 5]
console.log( Math.max(... list_number) )
// OUTPUT: 5
Example 5: Combine Multiple JSON Objects Using Spread Operator
const obj1 = {
"name": "Daniyal Akbar",
"age": 01
}
const obj2 = {
"gender": "male",
"height": 1.11
}
console.log(
{...obj1, ...obj2}
)
// OUTPUT: { name: 'Daniyal Akbar', age: 1, gender: 'male', height: 1.11 }
And that’s a wrap!
Hope you guys enjoyed this article and learned exactly what is spread operator in JavaScript and how it works. For more of these topics, please like this article and comment below.
Have a great one!
Recent Posts
- Казино Официальный Сайт Играть в Онлайн Казино Pin Up.2324
- Embrace the Spin Elevate Your Play with Captivating online casino slots & Unforgettable Jackpots.
- Elevate Your Play – Explore a Universe of Thrills with online casino slots and Claim Lucrative Rewar
- Hospitalier et attractif, le monde d’alexander casino vous attend
- Elevate Your Play with 30+ Payment Options & €1200 Bonus – Find Your Fortune at sky crown casino log
Recent Comments
Archives
- May 2026
- October 2025
- August 2025
- June 2025
- October 2024
- September 2024
- August 2024
- June 2023
- May 2023
- March 2023
- December 2022
- November 2022
- October 2022
- September 2022
- August 2022
- July 2022
- June 2022
- May 2022
- April 2022
- February 2022
- January 2022
- December 2021
- November 2021
- October 2021
- September 2021
- August 2021
- July 2021
Categories
- Angular
- AWS
- Backend Development
- Big Data
- Blog
- Casino
- Cloud
- Database
- Deployment
- DevOps
- Docker
- Frontend Development
- GitHub
- Google Cloud Platform
- Installations
- Java
- JavaScript
- Linux
- MySQL
- Networking
- News
- NodeJS
- Online casino
- Operating System
- Post
- Python
- Python Flask
- Report
- Security
- Server
- SpringBoot
- Subdomain
- TypeScript
- Uncategorized
- VSCode
- Webhosting
- WordPress
Search
Recent Post
Казино Официальный Сайт Играть в Онлайн Казино
- 19 May, 2026
- 1 min read
Embrace the Spin Elevate Your Play with
- 19 May, 2026
- 5 min read
Elevate Your Play – Explore a Universe
- 19 May, 2026
- 6 min read
Featured Videos
All Tags
Angular
API
AWS
Bash
Bash Scripting
Big Data
C Language
Cloud Server
Cluster
Command Line
CRUD
Database
Deployment
DevOps
Docker
Elementor
GitHub
Google Cloud
Google Cloud Platform
HBase Database
Header
installation
JasperReport
Java
JavaScript
Linux
Local Server
MySQL
NodeJS
npm
Programming
Publish
Puppeteer
Python
S3 Bucket
Security
SpringBoot
SSH
Terminal
ternary operators
TypeScript
Virtual Machines
Webhosting
Windows
WordPress