es6.array.of.js 612 B

12345678910111213141516171819
  1. 'use strict';
  2. var $export = require('./_export');
  3. var createProperty = require('./_create-property');
  4. // WebKit Array.of isn't generic
  5. $export($export.S + $export.F * require('./_fails')(function () {
  6. function F() { /* empty */ }
  7. return !(Array.of.call(F) instanceof F);
  8. }), 'Array', {
  9. // 22.1.2.3 Array.of( ...items)
  10. of: function of(/* ...args */) {
  11. var index = 0;
  12. var aLen = arguments.length;
  13. var result = new (typeof this == 'function' ? this : Array)(aLen);
  14. while (aLen > index) createProperty(result, index, arguments[index++]);
  15. result.length = aLen;
  16. return result;
  17. }
  18. });