Mostly that's due to JavaScript being a prototype-based language, as opposed to Java being a class-based one.
Depending on what you need getClass() for, there are several options in JavaScript:
Mostly that's due to JavaScript being a prototype-based language, as opposed to Java being a class-based one.
Depending on what you need getClass() for, there are several options in JavaScript:
A few examples:

function Foo() {}
var foo = new Foo();

typeof foo; // == "object"
typeof Foo; // == "function"

foo
instanceof Foo; // == true
foo
.constructor; // == Foo

Foo.prototype.isPrototypeOf(foo); // == true
Foo.prototype.bar = function (x) {return x+x;};
foo
.bar(21); // == 42


Tip 2:
to iterate over the json object in javasacript.
object_json = {'key1':'this is key1','key2':'this is key2'};


method :1:
for (var key in object_json){
console.log("key: "key+" value: "+ object_json[key]);
}

method: 2:










via prototype with forEach() which should skip the prototype chain properties:



Object.prototype.each = function(f) {
var obj = this
Object.keys(obj).forEach( function(key) {
f
( key , obj[key] )
});
}


//print all keys and values
var obj = {a:1,b:2,c:3}
obj
.each(function(key,value) { console.log(key + " " + value) });
// a 1
// b 2
// c 3

f you work with jQuery, you may use jQuery.each() method. It can be used to seamlessly iterate over both objects and arrays:



$.each(obj, function(key, value) {
console
.log(key, value);
});