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 :: sotre json on chrome storage 
Javascript :: generate guard angular 
Javascript :: for range python javascript 
Javascript :: how to convert entered number into currency in words in javascript 
Javascript :: substring method 
Javascript :: check if string contains at least one number javascript 
Javascript :: lodash remove element from list 
Javascript :: jquery contains text 
Javascript :: string contains string javascript 
Javascript :: $post in jquery 
Javascript :: brew node switch version 
Javascript :: install node on ubuntu and debian 
Javascript :: tailwind config 
Javascript :: React import image with url 
Javascript :: react-native run-ios command 
Javascript :: dynamic style react 
Javascript :: format a date moment 
Javascript :: shadow using react native 
Javascript :: how to link a photo in expo react native 
Javascript :: debounce react 
Javascript :: electron jquery 
Javascript :: javascript for...in with Arrays 
Javascript :: how remove last letter js 
Javascript :: how to load image from dir nodejs 
Javascript :: fadein fadeout jquery 
Javascript :: count word and space in text javascript 
Javascript :: vue.js slots 
Javascript :: what is type coercion in javascript 
Javascript :: React CKEditor Custom build 
Javascript :: if not undefined javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =