I have a problem that i didn't know how to solve it, i have test some information of how i should comparing or checking a variable if it was an array
or an object
I have tried this
console.log({} == []); // return false
console.log({1:"haha"} == {}); // return false
console.log(["haha"] == {}); // retun false
The problem is, that i want to know if a variable is actualy an object
cause typeof
of both []
or {}
return object
.
console.log(isobject({1:"haha"})) // should return true;
console.log(isobject(["haha"])); // should return false;
Or
console.log(isobject({})) // should return true;
console.log(isobject([])); // should return false;
Is there any function
to check variable
like above?
Thanks for any correction.
array instanceof Array
?