Skip to content

xiaohesong/babel-plugin-use-or-operator-for-destructuring-default-value

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to babel-plugin-use-or-operator-for-destructuring-default-value 👋

Version License: MIT

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!

About

es6 destructuring use or operator. When assign the default value for destructuring, used in falsly instead of undefined

Resources

Stars

Watchers

Forks

Packages

No packages published