lodashオブジェクト+巡回巡回+ソート
1._.forEach(collection,[iteratee=u.identity],[thisArg] 巡回する
_.forEach([22,33,11,55],function (value) {// , value
console.log(value);//22 33 11 55
});
_.forEach([22,33,11,55],function (value,index) {// value , index
console.log(value);
});
2._.sortBy(collection,[iteratee=u.identity],[thisArg] 匿名関数+文字列を並べ替えます.var arr = [
{name: 'bb',age:23},
{name: 'aa',age:22}
];
var arrSortResult = _.sortBy(arr, function(item){
return item.name;
});
_.forEach(arrSortResult, function(item){
console.log(item.name); //aa bb
});
var strSortResult = _.sortBy('cda').join('');//join() 。 。
console.log(strSortResult);//acd
3._.sorted Index(array,value,[iteratee=u.identity],[thisArg] :array
(Aray):検査が必要な配列 value
(*):挿入する判定パラメータ [iteratee=_.identity]
巡回方法 [thisArg]
(*): iteratee
のバインディング値var collection = ['a', 'b', 'c', 'd', 'f'];
console.log('before: ' + collection.join(' '));//before: a b c d f
var toBeInserted = 'e';
var sortedIndex = _.sortedIndex(collection, toBeInserted);
console.log("This is sortedIndex:"+sortedIndex);//This is sortedIndex:4
collection.splice(sortedIndex, 0, toBeInserted);
console.log('after:' + collection.join(' '));//after:a b c d e f
・