JSFiddle - React, Tailwind, and code Playground
JavaScript
var a =['suhdir', 'mohan'];
var b = [{
"name":[
{"key": "any key" }
]
}];
var test = Array.isArray(a);
var testB = Array.isArray(b);
console.log(test);
console.log(testB)
console.log(a);
function getType(p) {
if (Array.isArray(p)) return 'array';
else if (typeof p == 'string') return 'string';
else if (p != null && typeof p == 'object') return 'object';
else return 'other';
}
//var s = 'a string', a = [], o = {}, i = 5;
console.log("'s' is " + getType(a));
console.log("'a' is " + getType(b));
//console.log("'o' is " + getType(o));
//console.log("'i' is " + getType(i));