Javascript is_object
Returns true if variable is an object
Example 1
Running
1.is_object('23');
Could return
1.false
Example 2
Running
1.is_object({foo: 'bar'});
Could return
1.true
function is_object( mixed_var ){
// Returns true if variable is an object
//
// version: 810.114
// discuss at: http://phpjs.org/functions/is_object
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Legaev Andrey
// + improved by: Michael White (http://getsprink.com)
// * example 1: is_object('23');
// * returns 1: false
// * example 2: is_object({foo: 'bar'});
// * returns 2: true
// * example 3: is_object(null);
// * returns 3: false
if(mixed_var instanceof Array) {
return false;
} else {
return (mixed_var !== null) && (typeof( mixed_var ) == 'object');
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|