MDN

Array

 

1、The @@unscopable symbol property contains property names that were not included in the ECMAScript standard prior to the ES2015 version. These properties are excluded from with statement bindings.

2、When checking for Array instance, Array.isArray is preferred over instanceof because it works through iframes.over instanceof because it works through iframes.

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]

 

// Correctly checking for Array

Array.isArray(arr);  // true

// Considered harmful, because doesn't work through iframes

arr instanceof Array; // false

3、if (!Array.isArray) {

  Array.isArray = function(arg) {

    return Object.prototype.toString.call(arg) === '[object Array]';

  };

}

 

 

posted @ 2019-12-08 22:22  yeyexun  阅读(166)  评论(0)    收藏  举报