I need to print all datas in an object in a for loop but I don't know how to access to their index.
For example I have an object like this (this is an example ,but the real one is very big)
a = { name : richard ,last_name : stallman };
I can do this :
cnosole.log(a.name);
cnosole.log(a.last_name);
But the object is too big.How can I do this?
Our you could do it like this:
a = { name : 'richard' ,last_name : 'stallman' };
for( key in a){
console.log(a[key]);
}
You can convert an object to a string with JSON.stringify.
console.log(JSON.stringify(a));
should print something like:
{"name": "richard", "last_name": "stallman"}