javascript array has elements code example
Example 1: javascript check if array is not empty
if (array === undefined || array.length == 0) {
// array empty or does not exist
}
Example 2: how to check if an array contains a number in javascript
// To check if an array contains a number
const ratings = [1,2,3,4,5];
let result = ratings.includes(4);
console.log(result); // true
result = ratings.includes(6);
console.log(result); // false