Possible Duplicate:
Check that value is object literal?
I am working with an output that can be either null, 0, or a json object. And with that I need to come up with a means of determining if that output is indeed a real object. But I can't find anything that gives me a definitive answer as to if there is something like that in the javascript functionality or not. If there isn't is there a means otherwise that I can detect if this is an object?
isArray() method is used to check if an object is an array. The Array. isArray() method returns true if an object is an array, otherwise returns false .
You shouldn't use the typeof operator to check whether a value is an array, because typeof cannot distinguish between arrays and objects. Instead you should use Array. isArray() , because typeof would return 'object' , not 'array' . Array.
You can use the JavaScript Array. isArray() method to check whether an object (or a variable) is an array or not. This method returns true if the value is an array; otherwise returns false .
This isArray() Method in jQuery is used to determines whether the argument is an array. Parameters: The isArray() method accepts only one parameter that is mentioned above and described below: object : This parameter is the object to test whether or not it is an array.
JavaScript isArray() The JavaScript isArray() function determines whether the value given to this function is an array or not. If this argument is correct then this function is return true, otherwise it is false.
The isArray() method determines whether an object is an array. This function returns true if the object is an array, and false if not.
The isArray () method returns true if an object is an array, otherwise false. Array.isArray () is a static property of the JavaScript Array object.
Array.isArray () is a static property of the JavaScript Array object. You can only use it as Array.isArray (). Using x.isArray (), where x is an array will return undefined. Required. An object (or any data type) to be tested.
You can use typeof operator.
if( (typeof A === "object" || typeof A === 'function') && (A !== null) ) { alert("A is object"); }
Note that because typeof new Number(1) === 'object'
while typeof Number(1) === 'number';
the first syntax should be avoided.
use the following
It will return a true or false
theObject instanceof Object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With