diff --git a/lodash.js b/lodash.js index 8f9723b46..d5fadf1c4 100644 --- a/lodash.js +++ b/lodash.js @@ -1128,7 +1128,7 @@ */ function first(array, n, guard) { if (array) { - return (n == undefined || guard) ? array[0] : slice.call(array, 0, n); + return (n == null || guard) ? array[0] : slice.call(array, 0, n); } } @@ -1238,7 +1238,7 @@ if (!array) { return []; } - return slice.call(array, 0, -((n == undefined || guard) ? 1 : n)); + return slice.call(array, 0, -((n == null || guard) ? 1 : n)); } /** @@ -1296,7 +1296,7 @@ function last(array, n, guard) { if (array) { var length = array.length; - return (n == undefined || guard) ? array[length - 1] : slice.call(array, -n || length); + return (n == null || guard) ? array[length - 1] : slice.call(array, -n || length); } } @@ -1511,7 +1511,7 @@ if (!array) { return []; } - return slice.call(array, (n == undefined || guard) ? 1 : n); + return slice.call(array, (n == null || guard) ? 1 : n); } /** @@ -2255,7 +2255,7 @@ * // => { 'flavor': 'chocolate', 'sprinkles': 'rainbow' } */ var defaults = createIterator(extendIteratorOptions, { - 'inLoop': 'if (object[index] == undefined)' + extendIteratorOptions.inLoop + 'inLoop': 'if (object[index] == null)' + extendIteratorOptions.inLoop }); /** @@ -2525,8 +2525,8 @@ // treat `+0` vs. `-0` as not equal return a !== 0 || (1 / a == 1 / b); } - // a strict comparison is necessary because `null == undefined` - if (a == undefined || b == undefined) { + // a strict comparison is necessary because `undefined == null` + if (a == null || b == null) { return a === b; } // unwrap any wrapped objects diff --git a/lodash.min.js b/lodash.min.js index 0e628ea5a..13cbc90bc 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -4,12 +4,12 @@ */ ;(function(e,t){"use strict";function s(e){return"[object Arguments]"==it.call(e)}function o(e){return new u(e)}function u(e){if(e&&e._wrapped)return e;this._wrapped=e}function a(){for(var e,t,s,o=-1,u=arguments.length,a={e:"",f:"",k:"",q:"",c:{d:"",m:"++le?t():function(){if(1>--e)return t.apply(this,arguments)}},o.bind=N,o.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=At(e));for(var r=t.length;nw(i,e[n],r)&&t.push(e[n]);return t},o.escape=function(e){return e==r?"":(e+"").replace(B,c)},o.every=wt,o.extend=Lt,o.filter=Z,o.find=Et,o.first=y,o.flatten=b,o.forEach=St,o.forIn=dt,o.forOwn=ht,o.functions=At,o.groupBy=xt,o.has=function(e,t){return tt.call(e,t)},o.identity=k,o.indexOf=w,o.initial=function(e,n,r){return e?rt.call -(e,0,-(n==t||r?1:n)):[]},o.intersection=function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=rt.call(arguments,1);++rw(t,n)&&wt(s,function(e){return-1w(i,e[n],r)&&t.push(e[n]);return t},o.escape=function(e){return e==r?"":(e+"").replace(B,c)},o.every=wt,o.extend=Lt,o.filter=Z,o.find=Et,o.first=y,o.flatten=b,o.forEach=St,o.forIn=dt,o.forOwn=ht,o.functions=At,o.groupBy=xt,o.has=function(e,t){return tt.call(e,t)},o.identity=k,o.indexOf=w,o.initial=function(e,t,n){return e?rt.call +(e,0,-(t==r||n?1:t)):[]},o.intersection=function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=rt.call(arguments,1);++rw(t,n)&&wt(s,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},o.map=Nt,o.max=E,o.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},o.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0?e.length:Mt(e).length},o.some=pt,o.sortBy=function(e,n,r){if("string"==typeof n)var i=n,n=function(e){return e[i]};else r&&