TypeError: "x" is (not) "y"


错误消息:

TypeError: "x" is (not) "y"

Examples:
TypeError: "x" is undefined
TypeError: "x" is null
TypeError: "undefined" is not an object
TypeError: "x" is not an object or null
TypeError: "x" is not a symbol

出现了与期望不符的类型。

这个错误常常由 undefined 或 null 值引起。

此外,某些方法,例如 Object.create() 或 Symbol.keyFor(), 要求必须提供特定类型的参数。

解决方法

要解决空指针以及 undefined 或 null 值的问题, 你可以使用 typeof 操作符, 例如:

if (typeof foo !== 'undefined') {
  // Now we know that foo is defined, we are good to go.
}

相关阅读 >>

TypeError: "x" is (not) "y"

更多相关阅读请进入《TypeError》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...