Record

목차

개념

https://lodash.com/docs/4.17.15

https://www.measurethat.net/Benchmarks

###

users.find(function (o) { return o.age < 40; }) <- _.find(users, function (o) { return o.age < 40; })

numbers.filter(num => num % 3 === 0) <- _.filter(numbers, num => num % 3 === 0)

const [firstName, ...otherNames] = names <- const firstName = _.first(names); const otherNames = _.rest(names);

_.forEach([1, 2, 3], (value, index) => {
  console.log(value)
})
_.forEach({ 'a': 1, 'b': 2 }, (value, key) => {
  console.log(key);
});

elements.every(el => el.length == 3) //true <- _.every(elements, el => el.length == 3)

elements.some(el => el.startsWith('c')) <- _.some(elements, el => el.startsWith('c'))

primes.includes(79) <- _.includes(primes, 47)

_.uniq(elements)

_.compact(array) <- array.filter(Boolean)

testCopy = testArray.map(arr => arr); ← testCopy = _.cloneDeep(testArray);

_.uniqBy([{ ‘x’: 1 }, { ‘x’: 2 }, { ‘x’: 1 }], ‘x’);

_.unionBy([{ ‘x’: 1 }], [{ ‘x’: 2 }, { ‘x’: 1 }], ‘x’);

users.findIndex(u => u.age === 30) ← _.findIndex(users, u => u.age === 30)

_.remove(array, function(n) { return n % 2 == 0;});