es.array.join.js 686 B

123456789101112131415161718
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var IndexedObject = require('../internals/indexed-object');
  4. var toIndexedObject = require('../internals/to-indexed-object');
  5. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  6. var nativeJoin = [].join;
  7. var ES3_STRINGS = IndexedObject != Object;
  8. var STRICT_METHOD = arrayMethodIsStrict('join', ',');
  9. // `Array.prototype.join` method
  10. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  11. $({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD }, {
  12. join: function join(separator) {
  13. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  14. }
  15. });