Answers for "if array is empty javascrip"

24

javascript check if array is empty

if (typeof array !== 'undefined' && array.length === 0) {
    // the array is defined and has no elements
}
Posted by: Guest on March-13-2020
0

how to check empty string array in javascript

function checkEmptyString(item){
     if (item.trim().length > 0) return false;
     else return true;
    };
    
function checkIfArrayContainsEmptyString(array) {
  const containsEmptyString = array.some(checkEmptyString);
  return containsEmptyString;
};
    
console.log(checkIfArrayContainsEmptyString(["","hey","","this","is","my","solution"]))
// *returns true*

console.log(checkIfArrayContainsEmptyString(["yay","it","works"]))
// *returns false*
 Run code snippetHide results
Posted by: Guest on March-23-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language