I have an array called config
, in this array I have pushed several variables/objects (I'm not sure if variable or object is the correct term here) like this:
var config = [];
var example1 = { x : 12, y : 5 };
var example2 = { x : 17, y : 4 };
var example3 = { x : 11, y : 9 };
config.push(example1);
config.push(example2);
config.push(example3);
Now I want to get the names of all these variables/objects and do a console.log of their names. I have tried the following:
for(i = 0; i < config.length; i++)
{
console.log(config[i].constructor.name);
}
How do I get just the name of the variable/object? I don't want any of it's attributes or values, only the name. The loop should simply log to the console like:
example1
example2
example3