Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript remaining elements of an array to a variable using the spread syntax

const arrValue = ['one', 'two', 'three', 'four'];

// destructuring assignment in arrays
// assigning remaining elements to y
const [x, ...y] = arrValue;

console.log(x); // one
console.log(y); // ["two", "three", "four"]
 
PREVIOUS NEXT
Tagged: #javascript #remaining #elements #array #variable #spread #syntax
ADD COMMENT
Topic
Name
6+1 =