var _ = require('lodash'); _.compact([0, 1, false, 2, '', 3]); _.difference([1, 2, 3, 4, 5], [5, 2, 10]); var characters = [ { 'name': 'barney', 'age': 36, 'blocked': false }, { 'name': 'fred', 'age': 40, 'blocked': true }, { 'name': 'pebbles', 'age': 1, 'blocked': false } ]; _.findIndex(characters, function(chr) { return chr.age < 20; }); _.findIndex(characters, { 'age': 36 }); _.findIndex(characters, 'blocked'); _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); _.last([1, 2, 3]); _.last([1, 2, 3], 2); _.last([1, 2, 3], function(num) { return num > 1; }); _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); var array = [1, 2, 3, 1, 2, 3]; _.pull(array, 2, 3); console.log(array); _.range(4); _.range(1, 5); _.range(0, 20, 5); _.range(0, -4, -1); _.range(1, 4, 0); _.range(0); var array = [1, 2, 3, 4, 5, 6]; var evens = _.remove(array, function(num) { return num % 2 == 0; }); console.log(array); console.log(evens); _.rest([1, 2, 3]); _.rest([1, 2, 3], 2); _.rest([1, 2, 3], function(num) { return num < 3; });
|