Uncaught ReferenceError: Notification is not defined

This question already has an answer here:

  • JavaScript check if variable exists (is defined/initialized) 28 answers

  • You can use typeof like so:

    if (typeof Notification !== 'undefined') {
    
    }
    

    If you use typeof , it does not try to actually use the variable (which breaks and throws an error)

    链接地址: http://www.djcxy.com/p/95008.html

    上一篇: 检查变量是否设置的最佳方法是什么?

    下一篇: 未捕获的ReferenceError:通知未定义