using array isarray 28 29 method and array length

Solutions on MaxInterview for using array isarray 28 29 method and array length by the best coders in the world

showing results for - "using array isarray 28 29 method and array length"
Calum
28 Apr 2020
1// create empty array in javascript
2let empty_array = []
3
4// check empty is Array and then check array length
5if(Array.isArray(empty_array) && empty_array.length){
6
7  // if empty_array is a array and empty_array has a length
8  console.log("Array is not empty")
9 // iterate an array
10
11} else {
12  // either empty_array is empty
13   console.log("Empty Array")
14}
15// result => Empty Array