es6.array.of.js 544 B

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