js object destructuring with defaults
// Taken from top stack overflow answer
const { dogName = 'snickers' } = { dogName: undefined }
console.log(dogName) // what will it be? 'snickers'!
const { dogName = 'snickers' } = { dogName: null }
console.log(dogName) // what will it be? null!
const { dogName = 'snickers' } = { dogName: false }
console.log(dogName) // what will it be? false!
const { dogName = 'snickers' } = { dogName: 0 }
console.log(dogName) // what will it be? 0!let a, b;
[a=5, b=7] = [1];
console.log(a); // 1
console.log(b); // 7
Also in JavaScript:
- inject firebase in angularjs
- getelementsbytagname within a div
- javascript indexof with condition
- difference between key and code in javascript
- js prompt
- detecting change in animated value react native
- how to get csrf token in javascript
- mongodb delete duplicate documents
- node js check type of variable
- multiple event with javascript
- how to change class by is in js by toggle
- add element to array javascript
- how to return multiple values from a function javascript
- mongodb gte
- usestate hook
- javascript on click radio button get value
- angular 8 how to iterate json object in view
- node js change text color
- js array to csv
- how to push items in array in javascript
- javascript canvas ground zero
- three js examples
- creating js objects
- minecraft fps client that supports linux