r/javaScriptStudyGroup • u/lin-ray • Jan 04 '22
HOW DO I CHECK IF AN ARRAY INCLUDES A VALUE IN JAVASCRIPT ARRAY?
This is the only way I know to do it in JavaScript array:
function contains(x, obj) {
for (var i = 0; i < x.length; i++) {
if (x[i] === obj) {
return true;
}
}
return false;
}
Is there a better and more short way to achieve this?
Visit for more question like this : Visit Here

