1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 1 13 86 86 2 84 1 | define(function(){ /** * internal method used to create other collection modules. */ function makeCollectionMethod(arrMethod, objMethod, defaultReturn) { return function(){ var args = Array.prototype.slice.call(arguments); if (args[0] == null) { return defaultReturn; } // array-like is treated as array return (typeof args[0].length === 'number')? arrMethod.apply(null, args) : objMethod.apply(null, args); }; } return makeCollectionMethod; }); |