我试图了解如何使用默认参数对false值和null值进行解构.以下是我跑过的一些例子:
// #1
const person = { email: 'a@example.com' }
const { email = '' } = person
// email is 'a@example.com'
// #2
const person = { email: '' }
const { email = '' } = person
// email is ''
// #3
const person = { email: false }
const { email = '' } = person
// email is boolean false. why?!
// #4
const person = { email: null }
const { email = '' …Run Code Online (Sandbox Code Playgroud)