A collection of useful static methods to deal with JavaScript arrays.
- Since:
- 1.0.0
Methods
(static) getNullSafe(arr) → {Array}
Returns a non-null array, even if the object being passed is a null array.
If the passed-in object is a non-null array, then it is returned as-is.
Example usage:
var arr1 = [1, 2, 3, 4];
var arr2 = null;
var arr3 = mindsmine.Array.getNullSafe(arr1);
var arr4 = mindsmine.Array.getNullSafe(arr2);
// arr3 now contains the array: [1, 2, 3, 4]
// arr4 now contains the array: []
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | The array to safeguard against |
- Since:
- 1.0.0
Returns:
If arr is null
then []
(empty array).
- Type
- Array