JavaScript SPREAD OPERATOR in 4 minutes! 📖

Published: 07 November 2023
on channel: Bro Code
35,751
1.1k

// spread operator = ... allows an iterable such as an
// array or string to be expanded
// in to separate elements
// (unpacks the elements)

// ------------ EXAMPLE 1 ------------
let numbers = [1, 2, 3, 4, 5];
let maximum = Math.max(...numbers);
let minimum = Math.min(...numbers);

console.log(maximum);

// ------------ EXAMPLE 2 ------------
let username = "Bro Code";
let letters = [...username];

console.log(letters);

// ------------ EXAMPLE 3 ------------
let fruits = ["apple", "orange", "banana"];
let vegetables = ["carrots", "celery", "potatoes"];
let foods = [...fruits, ...vegetables, "eggs", "milk"];

console.log(foods);


On this page of the site you can watch the video online JavaScript SPREAD OPERATOR in 4 minutes! 📖 with a duration of hours minute second in good quality, which was uploaded by the user Bro Code 07 November 2023, share the link with friends and acquaintances, this video has already been watched 35,751 times on youtube and it was liked by 1.1 thousand viewers. Enjoy your viewing!