Answers for "creating variables with destructured array"

0

Destructuring of array in ES6

function printFirstAndSecondElement([first, second]) {
    console.log('First element is ' + first + ', second is ' + second)
}

function printSecondAndFourthElement([, second, , fourth]) {
    console.log('Second element is ' + second + ', fourth is ' + fourth)
}

var array = [1, 2, 3, 4, 5]

printFirstAndSecondElement(array)
printSecondAndFourthElement(array)
Posted by: Guest on April-10-2022

Code answers related to "creating variables with destructured array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language