Answers for "make sure array is null"

0

Check If An Array Is Empty Or Null Or Undefined In JavaScript?

let myArray = [];

if( myArray.length  > 0  ) {
    console.log(myArray);
    console.log("Array has elements");
}
else {
    console.log("Array has no elements");
}
Posted by: Guest on August-09-2021
0

non null array length

public static <T> int getLength(T[] arr){
    int count = 0;
    for(T el : arr)
        if (el != null)
            ++count;
    return count;
}

// equivalently in pure C# :
public static int getUsedLength(string[] arr)
        {
            int count = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] != null)
                { 
                    ++count; 
                }
            }
            return count;
        }
Posted by: Guest on April-15-2020

Code answers related to "make sure array is null"

Code answers related to "Javascript"

Browse Popular Code Answers by Language