我知道一种判断数组的方法是typeof arr instanceof Array.但是在网上看到说什么在不同框架下就不能这么判断?什么iframe的,怎么样才算不一样的框架?能举个例子吗?
v instanceof Array will return false if v was created in another frame (v is instance of thatFrame.contentWindow.Array class).
我知道一种判断数组的方法是typeof arr instanceof Array.但是在网上看到说什么在不同框架下就不能这么判断?什么iframe的,怎么样才算不一样的框架?能举个例子吗?
v instanceof Array will return false if v was created in another frame (v is instance of thatFrame.contentWindow.Array class).
用instanceof typeof 本来就不是一个好方法
Object.prototype.toString.call(arr).toUpperCase() === "[OBJECT ARRAY]"
13 回答13k 阅读
7 回答2.2k 阅读
3 回答1.4k 阅读✓ 已解决
6 回答1.4k 阅读✓ 已解决
2 回答1.4k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
6 回答1.2k 阅读
一个例子:
原文地址:
instanceof
considered harmful (or how to write a robustisArray
)