Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript spread and rest operator

let array1 = ["one", "two", "three", "four"]
let array2 = ["five", "six", "seven"]

// Spread operator
let finalArray = [...array1, ...array2]
console.log(finalArray)
// output: ["one", "two", "three", "four", "five", "six", "seven"]

// rest operator
let [first, ...rest] = array1
console.log(first) //output:  one
console.log(rest)  // output: ["two", "three", "four"]
Comment

spread and rest javascript

var myName = ["Marina" , "Magdy" , "Shafiq"];var newArr = [...myName ,"FrontEnd" , 24];console.log(newArr) ; // ["Marina" , "Magdy" , "Shafiq" , "FrontEnd" , 24 ] ;
Comment

spread and rest javascript

var myName = ["Marina" , "Magdy" , "Shafiq"] ;const [firstName , ...familyName] = myName ;console.log(firstName); // Marina ;console.log(familyName); // [ "Magdy" , "Shafiq"] ;
Comment

Rest and spread operators in ES6

var array = ['red', 'blue', 'green']
var copyOfArray = [...array]

console.log('Copy of', array, 'is', copyOfArray)
console.log('Are', array, 'and', copyOfArray, 'same?', array === copyOfArray)
Comment

PREVIOUS NEXT
Code Example
Javascript :: speech to text in js 
Javascript :: jquery dom traversal parent 
Javascript :: mapbox add a leaflet marker with popup 
Javascript :: how to make a div auto refresh js 
Javascript :: if without else javascript 
Javascript :: how to decode jwt token in react 
Javascript :: how to append a data to list in redux 
Javascript :: clear dict javascript 
Javascript :: restart bot discord.js 
Javascript :: unknown provider angularjs 
Javascript :: exclude vales from array in js 
Javascript :: js include another 
Javascript :: password generator 
Javascript :: jQuery - Remove 
Javascript :: find vowels in string javascript 
Javascript :: inline style to change background color javascript 
Javascript :: JavaScript Destructuring - From ES6 
Javascript :: javascript record video in browser 
Javascript :: js clone obj 
Javascript :: electronjs 
Javascript :: mongoose node js 
Javascript :: javascript addeventlistener pass parameters 
Javascript :: get width of html photo 
Javascript :: javascript switch items in array 
Javascript :: js console log 
Javascript :: create random password 
Javascript :: how to check if it is the current time day.js 
Javascript :: how to change Mime type of a file express 
Javascript :: nodejs redis 
Javascript :: js fadeout 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =