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 :: how to start react project on atom 
Javascript :: javascript entries() method 
Javascript :: npm: Create react chrome extension 
Javascript :: nesting express routes 
Javascript :: sort array in ascending order javascript 
Javascript :: how to decode jwt token at frontend 
Javascript :: connectedcallback web components 
Javascript :: updatig state in react 
Javascript :: .index of javascript 
Javascript :: object loop 
Javascript :: check if something is a letter in js 
Javascript :: visual studio code json to one line 
Javascript :: how to disable button if errors object isnt empty in react hook form 
Javascript :: compare date value in javascript 
Javascript :: stripe delete product 
Javascript :: css using inline styles 
Javascript :: library for react table 
Javascript :: luxy js 
Javascript :: push method in javascript 
Javascript :: angular material open last visited tab 
Javascript :: method example js 
Javascript :: Discord.js v13 / command handler 
Javascript :: typescript compile string to js 
Javascript :: fivem server discord.js 
Javascript :: desestructuración javascript 
Javascript :: strong password javascript 
Javascript :: import math javascript 
Javascript :: jquery get last element with two class name 
Javascript :: multiple refs react 
Javascript :: what does return do in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =