操作符
#Script
- ?? 与 || 相同
解释:
null
,undefined
类型执行后面语句,默认情况下返回左边值
let test1 = null
let test2 = undefined
let test11 = test1 || '' // ''
let test21 = test2 || '' // ''
- ||
解释: null
, undefined
, ''
类型则执行后面语句
let test1 = null
let test2 = undefined
let test3 = ''
let test11 = test1 || '' // ''
let test21 = test2 || '' // ''
let test31 = test3 || '' // ''
- &&