Answers for "how to check if string array is empty"

3

check if an array is empty javascript

if (!Array.isArray(array) || !array.length) {
  // array does not exist, is not an array, or is empty
  // ⇒ do not attempt to process array
}
Posted by: Guest on October-03-2021
0

If Array Is Empty

const isNotEmpty = arr => Array.isArray(arr) && arr.length > 0;

isNotEmpty([1, 2, 3]);
// Result: true
Posted by: Guest on January-07-2022

Code answers related to "how to check if string array is empty"

Code answers related to "Javascript"

Browse Popular Code Answers by Language