Say I have an array of objects like this:
function obj (name) {
this.name = name
}
let x = {
'foo': new obj('foo');
'bar': new obj('bar');
}
Is there an advantage to using x['foo'].name
over x['foo']['name]
?
I recognize that []
notation is a lot more versatile when it comes to adding things to an object or when looping through an object with for
so is there any reason besides ease of use that one would choose to access it with .
? Does it provide a speed increase or is it just for readability?