Sorry if this has been asked before, but I need a much more straightforward answer than some of the complex examples I've found in my search...
If I create several global objects, let's say they're named Johnson
, Smith
, etc, and afterwards I push them to a global array called people
, like people[0] = Johnson
, people[1] = Smith
...
Have I simply created a reference to that global object, or some sort of duplicate within the array?
So if I choose to add a new property to every object by iterating over the array, people[i].newProperty
, am I just adding a new property to the original global object, or to the global object and the object within the array?
Secondly, would there be any sort of performance hit when assigning properties through the array versus creating the global objects inside of a single global object at the very beginning, like People.Johnson
? I'm guessing there's no difference, but thought I would throw it out there.
Thanks!