Uncaught ReferenceError: Notification is not defined
This question already has an answer here:
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)
上一篇: 检查变量是否设置的最佳方法是什么?