Skip to content

Instantly share code, notes, and snippets.

@billyma128
Last active March 13, 2017 09:29
Show Gist options
  • Save billyma128/74ba093df14be827174f33b6296dd54f to your computer and use it in GitHub Desktop.
Save billyma128/74ba093df14be827174f33b6296dd54f to your computer and use it in GitHub Desktop.
为什么在js里用 instanceof 和 constructor 不能完美判断一个数组是不是数组?
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
xArray = window.frames[window.frames.length-1].Array;
var arr = new xArray(1,2,3); // [1,2,3]

// Boom!
arr instanceof Array; // false

// Boom!
arr.constructor === Array; // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment