【问题标题】:What does double question mark mean in javascript / typescript? [duplicate]javascript / typescript中的双问号是什么意思? [复制]
【发布时间】:2021-07-23 17:59:42
【问题描述】:

我看到了这段代码,但不明白这个符号在 Javascript 或打字稿中的含义:

const _apolloClient = apolloClient ?? createApolloClient(context);

【问题讨论】:

    标签: javascript typescript symbols


    【解决方案1】:

    像我这样懒惰的人的简短回答:

    如果 firstValuenullundefined

    console.log(firstValue ?? secondValue) // secondValue
    

    如果 firstValue 不是 nullundefined

    console.log(firstValue ?? secondValue) // firstValue
    

    【讨论】:

      猜你喜欢
      • 2014-07-28
      • 2016-12-23
      • 2018-06-23
      • 1970-01-01
      • 1970-01-01
      • 2011-01-17
      • 2015-07-15
      • 2018-07-17
      相关资源
      最近更新 更多