how to check if something is an array code example
Example 1: js test if array
if(Array.isArray(myVarToTest)) {
} else {
}
Example 2: how to check if something is array javascript
function isArray(value) {
return Object.prototype.toString.call(value) === "[object Array]";
}
Example 3: how to check if array
Array.isArray([1, 2, 3]);
Array.isArray('asdf');
Example 4: how to recognize an array in javascript
const array = [1, 2, 3];
Array.isArray(array);
Array.isArray(object);
Array.isArray(string);
Array.isArray(empty);
({}).toString.call(array);
({}).toString.call(object);
({}).toString.call(string);
({}).toString.call(empty);