Answers for "check if arr has item"

9

check if a variable is array in javascript

// inside if else check
if(Array.isArray(myVarToTest)) {
	// myVatToTest is an array
} else {
	// myVarToTest is not an array
}
Posted by: Guest on January-08-2021
0

Check if an array contains a number in javascript

const ratings = [1,2,3,4,5];

let result = ratings.includes(4); 
console.log(result); // true

result = ratings.includes(6); 
console.log(result); // false
Posted by: Guest on April-06-2022

Code answers related to "check if arr has item"

Code answers related to "Javascript"

Browse Popular Code Answers by Language