Skip to main content

操作符

#Script

  1. ?? 与 || 相同 解释: null, undefined类型执行后面语句,默认情况下返回左边值
let test1 = null
let test2 = undefined

let test11 = test1 || '' // ''
let test21 = test2 || '' // ''
  1. ||

解释: null, undefined, ''类型则执行后面语句

let test1 = null
let test2 = undefined
let test3 = ''

let test11 = test1 || '' // ''
let test21 = test2 || '' // ''
let test31 = test3 || '' // ''
  1. &&