Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to Copy an Array With the Spread Operator in JavaScript

let studentNames = ["Daniel", "Jane", "Joe"];

let names = [...studentNames];

console.log(names); // ["Daniel","Jane","Joe"]

// This saves us the time we would use to write a loop statement:
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #How #Copy #Array #With #Spread #Operator #JavaScript
ADD COMMENT
Topic
Name
1+1 =