javascript nested array destructuring
let arr = [1, 2, 3, 4, [100, 200, 300], 5, 6, 7];
// nested array destructuring
const [a, , , , [, b, ,], , , ,] = arr;
console.log(a);
// expected output "1"
console.log(b);
// expected output "200"//simple example with object------------------------------
let obj = {name: 'Max', age: 22, address: 'Delhi'};
const {name, age} = obj;
console.log(name);
//expected output: "Max"
console.log(age);
//expected output: 22
console.log(address);
//expected output: Uncaught ReferenceError: address is not defined
// simple example with array-------------------------------
let a, b, rest;
[a, b] = [10, 20];
console.log(a);
// expected output: 10
console.log(b);
// expected output: 20
[a, b, ...rest] = [10, 20, 30, 40, 50];
console.log(rest);
// expected output: Array [30,40,50]
Also in JavaScript:
- Javascript get month name
- Changes not staged for commit: modified: ../package.json
- js capitalize first letter of each word
- class in side class in jss
- get css value jquery
- some in javascript
- how to get connection string value from appsettings.json in .net core
- how to remove an element javascript html
- javascript math min array
- javascript function call with variable
- calcular sobra de divisão de parcelas js
- three js cdn
- vscode pylint disable Module name doesn't conform to snake_case naming style
- floor in js
- javascript rect
- react router url params
- how to setstate in parent in child component in react native
- set a variable in express.js
- jquery direct window print pdf
- manifest.webmanifest example
- objeto con método javascript
- fabric js background pathern
- parse json to dart model
- js get first 3 characters of string