Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.

Latest commit

 

History

History

destructuring

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Destructuring

Array Destructuring

let [ one, two ] = [ 1, 2 ];
console.log('one =', one, '; two =', two);

in Function calls

function foo([one, two]) {
	console.log('one =', one, '; two =', two);
}

foo([1,2]);

Object Destructuring

let {three, four} = {three: 3, four:  4};
console.log('three =', three, '; four =', four);

in Function calls

function foo({ three, four }) {
	console.log('three =', three, '; four =', four);
}

foo({ three: 3, four: 4 });