var wrapped = _([1, 2, 3]);
// 在 3.10.1
wrapped.forEach(function(n) { console.log(n); });
// → returns the lodash wrapper without logging until `value` is called
// → 在 `value` 调用之前返回 lodash 包装器(并不会打印记录)
wrapped.forEach(function(n) { console.log(n); }).value();
// → logs each value from left to right and returns the array
// → 从左到右记录每个值,并返回该数组
// 在 4.0.0
wrapped.forEach(function(n) { console.log(n); });
// → logs each value from left to right and returns the array
// → 从左到右记录每个值,并返回该数组
// in 3.10.1
var chunk = require('lodash/array/chunk');
// in 4.0.0
var chunk = require('lodash/chunk');
var objects = [{ 'a': 1 }, { 'a': 2 }];
// in 3.10.1
_.pluck(objects, 'a'); // → [1, 2]
_.map(objects, 'a'); // → [1, 2]
// in 4.0.0
_.map(objects, 'a'); // → [1, 2]
var objects = [{ 'a': 1 }, { 'a': 2 }];
var context = { 'b': 5 };
function callback(item) {
return item.a + this.b;
}
// in 3.10.1
_.map(objects, callback, context);
// in 4.0.0
_.map(objects, _.bind(callback, context));
var array = [1, 2, 3],
objects = [{ 'a': 1 }, { 'a': 2 }];
// in 3.10.1
_.max(array); // → 3
_.max(objects, 'a'); // → { 'a': 2 }
_.min(array); // → 1
_.min(objects, 'a'); // → { 'a': 1 }
// in 4.0.0
_.max(array); // → 3
_.maxBy(objects, 'a'); // → { 'a': 2 }
_.min(array); // → 1
_.minBy(objects, 'a'); // → { 'a': 1 }
.assignIn, .before, .bind, .chain, .clone, .compact, _.concat,
.create, .defaults, .defer, .delay, .each, .escape, _.every,
.filter, .find, .first, .flatten, .flattenDeep, .forEach,
.has, .head, .identity, .indexOf, .invokeMap, .isArguments,
.isArray, .isBoolean, .isDate, .isEmpty, .isEqual, .isFinite,
.isFunction, .isNaN, .isNull, .isNumber, .isObject, .isRegExp,
.isString, .isUndefined, .iteratee, .keys, .last, .map,
.max, .min, .mixin, .negate, .noConflict, .noop, _.now,
.once, .pick, .reduce, .result, .size, .slice, _.some,
.sortBy, .tap, .thru, .toArray, .uniqueId, .value, & _.values
.concat, .differenceBy, .differenceWith, .flatMap, .fromPairs, .intersectionBy,
.intersectionWith, .join, .pullAll, .pullAllBy, .reverse, .sortedIndexBy, _.sortedIndexOf,
.sortedLastIndexBy, .sortedLastIndexOf, .sortedUniq, .sortedUniqBy, _.unionBy,
.unionWith, .uniqBy, .uniqWith, .xorBy, & _.xorWith
.cloneDeepWith, .cloneWith, .eq, .isArrayLike, .isArrayLikeObject, .isEqualWith, _.isInteger,
.isLength, .isMatchWith, .isNil, .isObjectLike, .isSafeInteger, .isSymbol, _.toInteger,
.toLength, .toNumber, .toSafeInteger, & .toString
.assignIn, .assignInWith, .assignWith, .functionsIn, .hasIn, .invoke, _.mergeWith,
.omitBy, .pickBy, .setWith, .toPairs, .toPairsIn, & .unset
.lowerCase, .lowerFirst, .replace, .split, .upperCase, .upperFirst, .toLower, & .toUpper
- 8 个 utility 方法:
.cond, .conforms, .nthArg, .over, .overEvery, .overSome, .rangeRight, & .toPath
- 4 个 math 方法:
.maxBy, .mean, .minBy, & .sumBy
- 2 个 function 方法:
.flip & .unary
- 2 个 number 方法:
.clamp & .subtract
- 1 个 chain 方法:
_#next
- 1 个 collection 方法:
_.sampleSize
- 添加 3 别名
1. .extend 作为 .assignIn 的别名
2. .extendWith 作为 .assignInWith 的别名
3. .first 作为 .head 的别名
- 移除 17 个别名
.all, .any, .backflow, .callback, .collect, .compose, _.contains,
.detect, .foldl, .foldr, .include, .inject, .methods, _.object,
.#run, .select, & _.unique