I am using JavaScript. I have an object. I then place that object inside an array that I initialize. I then do some work on that array and the value(s) inside it. I'm hoping to know if, by changing the object in the array, I am also changing the actual object itself? Code below.
function doStuff() {
var node = getNode(); //getNode() returns a node object
var queue = [node]; //This is the line my question is about
while(queue.length > 0) {
//Add data to queue[0]. Add queue[0]'s children to queue, remove queue[0]
}
return node;
};
So, when the while loop finishes, will node be pointing to the changed object, or will it just hold a copy of the object from before it was put into the queue?
I appreciate any help, many thanks!