mirror of
https://github.com/hanzoai/es5-ext.git
synced 2026-09-24 16:58:43 +00:00
- Array.from always returns copy of input array - Array.from implements optional mapping functionality - Array.toArray was introduced as alternative that does not produce copy of an array if it's not needed - Array#copy was removed, as same now can be achived by Array.from Array.from doesn't follow ES6 spec in full: - It doesn't support iterators (which are non existent and cannot be fully shimmed in ES5) - It doesn't produce array subclasses if it's called in context of such constructors. Array subclasses are not possible in plain ES5 (note: still in many implementations they can be produced with help of `__proto__`, so this part may be subject to changes)
10 lines
176 B
JavaScript
10 lines
176 B
JavaScript
'use strict';
|
|
|
|
var from = require('./from')
|
|
|
|
, isArray = Array.isArray;
|
|
|
|
module.exports = function (arrayLike) {
|
|
return isArray(arrayLike) ? arrayLike : from(arrayLike);
|
|
};
|