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 :: Implicit returns in ES6 
Javascript :: Classes and constructor functions in ES6 
Javascript :: on click disable esc button using jquery 
Javascript :: date filter in angular 8 
Javascript :: angular 8 input decorator Expected 2 arguments, but got 1. 
Javascript :: material ui table row onclick 
Javascript :: javascript array keyshort 
Javascript :: Getting error after I put Async function in useEffect 
Javascript :: image support in node js chat app 
Javascript :: javascript span containing text 
Javascript :: replace div content javascript 
Javascript :: Learning Arrow function Syntax 
Javascript :: unique in order codewars javascript 
Javascript :: react redux open another page 
Javascript :: my saved scripts 
Javascript :: how to apply scrollbar in textarea 
Javascript :: browserslist 
Javascript :: whatisjsx 
Javascript :: adding items to extjs container 
Javascript :: How to check for the properties of an element in the console 
Javascript :: get twitter username from string javascript 
Javascript :: map vs subscribe angular 
Javascript :: element vs node 
Javascript :: Arrays in Apps Script 
Javascript :: use only dispatch from useContext 
Javascript :: javascript paragraph class 
Javascript :: how to install ruchi js 
Javascript :: creating XML object 
Javascript :: how to disable gravity for an object in matter.js 
Javascript :: browser console noting displayed 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =