https://github.com/sstephenson/prototype/blob/1fb972开发者_运维技巧8/src/lang/array.js#L104
I need to separate Array.from() method from prototype js and implement it in jQuery. any idea where to start?
$A is just a variable for this function:
function $A(iterable) {
if (!iterable) return [];
// Safari <2.0.4 crashes when accessing property of a node list with property accessor.
// It nevertheless works fine with `in` operator, which is why we use it here
if ('toArray' in Object(iterable)) return iterable.toArray();
var length = iterable.length || 0, results = new Array(length);
while (length--) results[length] = iterable[length];
return results;
}
Array.from = $A;
...
Array.from("a,b,c,e,d") // outputs: ["a", ",", "d", ",", "f", ",", "e", ",", "e"]
精彩评论