let array = [1234, 1233, 1232];
console.log(_.some(array, 1234));
It returns false
. Do you know why?
let array = [1234, 1233, 1232];
console.log(_.some(array, 1234));
It returns false
. Do you know why?
As per the documentation of _.some()
method, second argument should be a predicate function
console.log(_.some(array, function(v){ return v === 1234}));
Array#indexOf
method.
console.log(array.indexOf(1234) > -1);
Array#some
method.
console.log(array.some(function(v){ return v === 1234}));
with ES6 arrow function
console.log(array.some(v => v == 1234))
With UNDERSCORE.JS you can simply use,
console.log(_.indexOf(array, 1234) >= 0)
Document for more details: http://underscorejs.org/#indexOf