This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const animals = ['ant', 'bison', 'camel', 'duck', 'elephant']; | |
console.log(_.slice(animals,2)); | |
// expected output: Array ["camel", "duck", "elephant"] | |
console.log(_.slice(animals,2, 4)); | |
// expected output: Array ["camel", "duck"] | |
console.log(_.slice(animals,1, 5)); | |
// expected output: Array ["bison", "camel", "duck", "elephant"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// intersection | |
_.intersection([2, 1], [2, 3]); | |
// => [2] | |
// intersectionBy | |
_.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); | |
// => [2.1] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dropWhile | |
var users = [ | |
{ 'user': 'barney', 'active': false }, | |
{ 'user': 'fred', 'active': false }, | |
{ 'user': 'pebbles', 'active': true } | |
]; | |
_.dropWhile(users, function(o) { return !o.active; }); | |
// => objects for ['pebbles'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.dropRight([1, 2, 3]); | |
// => [1, 2] | |
_.dropRight([1, 2, 3], 2); | |
// => [1] | |
_.dropRight([1, 2, 3], 5); | |
// => [] | |
_.dropRight([1, 2, 3], 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.drop([1, 2, 3]); | |
// => [2, 3] | |
_.drop([1, 2, 3], 2); | |
// => [3] | |
_.drop([1, 2, 3], 5); | |
// => [] | |
_.drop([1, 2, 3], 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); | |
// => [1.2] | |
// The `_.property` iteratee shorthand. | |
_.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); | |
// => [{ 'x': 2 }] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.difference([2, 1], [2, 3]); | |
// => [1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var array = [1]; | |
var other = _.concat(array, 2, [3], [[4]]); | |
console.log(other); | |
// => [1, 2, 3, [4]] | |
console.log(array); | |
// => [1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.compact([0, 1, false, 2, '', 3]); | |
// => [1, 2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.chunk(['a', 'b', 'c', 'd'], 2); | |
// => [['a', 'b'], ['c', 'd']] | |
_.chunk(['a', 'b', 'c', 'd'], 3); | |
// => [['a', 'b', 'c'], ['d']] |