Reputation: 76
I have some objects:
var obj1 = new Obj1(),
obj2 = new Obj2(),
...
and two arrays:
objecs.push(obj1, obj2,...);
defaultObjects.push(obj1, obj2, ...);
During the game loop objects
array changes, but defaultObjects
does not.
When the game needs to be restarted, I need to make objects
equal to defaultObjects
(just like it was in the beginning).
if I do this:
objects = defaultObjects.slice(0)
does it mean that objects[0]
and defaultObjects[0]
are now pointing at the same object obj1
, but there is no connection between objects
and defaultObjects
so I get what I need?
Upvotes: 0
Views: 148