1.0.4 • Published 4 years ago
babel-plugin-use-or-operator-for-destructuring-default-value v1.0.4
destructuring default value use
||
, without undefined only
Install
yarn add babel-plugin-use-or-operator-for-destructuring-default-value
why write it
before used this babel
const user = {name: 'xiaohesong', age: null, sex: ''}
const {name, age = 18, sex = 'man'} = user
console.log(name, age, sex) // xiaohesong null
used
const user = {name: 'xiaohesong', age: null, sex: ''}
const {name, age = 18, sex = 'man'} = user
console.log(name, age, sex) // xiaohesong 18 man
Show your support
Give a ⭐️ if this project helped you!