0
点赞
收藏
分享

微信扫一扫

js中使用两个问号

code_balance 2022-03-23 阅读 35
esjavascript
const response = {
  settings: {
    nullValue: null,
    height: 800,
    carNum: 0,
    headerText: '',
    showSplashScreen: false
  }
};
const undefinedValue = response.settings.undefinedValue ?? 'some other default'; // result: 'some other default'
const headerText = response.settings.headerText ?? 'Hello, world!'; // result: ''
const animationDuration = response.settings.carNum?? 300; // result: 0
const showSplashScreen = response.settings.showSplashScreen ?? true; // result: false
举报

相关推荐

0 条评论