0
これは_.initial
ためunderscore.js
のコードです:_nditialはUnderscore.jsにあるよりも詳細ですか?
// Returns everything but the last entry of the array. Especially useful on
// the arguments object. Passing **n** will return all the values in
// the array, excluding the last N.
_.initial = function(array, n, guard) {
return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
};
次のようにそれほど冗長と同等になるように私には思える:そのような詳細について尋ねる
_.initial = function(array, n, guard) {
return slice.call(array, 0, Math.min(0, -(n == null || guard ? 1 : n)));
};
があるため場違いではありませんはできるだけ多くのバイトを保存しようとします。たとえば、次のコメントを参考にしてください。
// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
もっと冗長なコードが必要な理由はありますか?