Answers for "array destructuring methods parameters"

1

destructuring Array in JavaScript

let [greeting = "hi",name = "Sarah"] = ["hello"];

console.log(greeting);//"Hello"
console.log(name);//"Sarah"
Posted by: Guest on May-25-2021
1

array destructuring in javascript

const array = ['ismail', 'sulman'];
// array destructuring
const [firstElement, secondElement] = array;
console.log(firstElement, secondElement);
const secondArray = ['ismail', 'naeem', 'Mr', 1];
const [firstEl, secondEl, ...array1] = secondArray;
console.log(firstEl, secondEl, array1);
Posted by: Guest on December-12-2020
0

array destructuring methods parameters

function foo([a, b]) {
   console.log(`param1: ${a}, param2: ${b}`);
}
Posted by: Guest on January-05-2021
0

array destructuring methods parameters

const items = [ ['foo', 3], ['bar', 9] ];
items.forEach(([word, count]) => {
    console.log(word+' '+count);
});
Posted by: Guest on January-05-2021
0

destructuring Array in JavaScript

function getArray() {
    return ["Hello", "I" , "am", "Sarah"];
} 
let [greeting,pronoun] = getArray();

console.log(greeting);//"Hello"
console.log(pronoun);//"I"
Posted by: Guest on May-25-2021

Code answers related to "array destructuring methods parameters"

Code answers related to "Javascript"

Browse Popular Code Answers by Language