TIL JS Object destructuring
POSTED ON:
TAGS: javascript
The basic syntax of object destructuring
const animation = {
provider: 'Netflix',
title: 'Avatar: The Last Airbender'
}
const { provider } = animation; // => 'Netflix'
Add a object directly into an array
const animation = {
provider: 'Netflix',
title: 'Avatar: The Last Airbender',
mainCharacter: 'Aang'
}
const { provider, mainCharacter } = animation;
provider; // => 'Netflix'
mainCharacter; // => 'Aang'
Add a object directly into an array
This one is pretty neat. It's a shortcut.
{name: fruits[fruits.length]} = {name: 'cherry'}
//fruits is now ['banana', 'apple', 'kumquat', 'cherry']
ref
ref - destructure into array
Related TILs
Tagged: javascript