Answers for "JAVASCRIPT TO check a value exists"

15

javascript check if variable exists

if (typeof myVar !== 'undefined') {
    // myVar is defined
}
Posted by: Guest on July-23-2019
-2

Checking whether a value exists in an array javascript

const fruits = ['apple', 'banana', 'mango', 'guava'];

function checkAvailability(arr, val) {
  return arr.some(arrVal => val === arrVal);
}

checkAvailability(fruits, 'kela');   // false
checkAvailability(fruits, 'banana'); // true
Posted by: Guest on December-08-2020

Code answers related to "JAVASCRIPT TO check a value exists"

Code answers related to "Javascript"

Browse Popular Code Answers by Language