why does my variable seem to be updating?
<p>I'm currently learning JavaScript and as far as I know have not learned anything that could explain the following:</p>

<pre><code>&lt;div id="parent"&gt;
    &lt;div&gt;One&lt;/div&gt;
    &lt;div&gt;Two&lt;/div&gt;
&lt;/div&gt;
&lt;script&gt;
    function test(node) {
        var divs = node.children;
        console.log(divs);
        var div = document.createElement("div");
        node.appendChild(div);
        console.log(divs);
    }
    test(document.querySelector("#parent"));
&lt;/script&gt;
</code></pre>

<p>I want the variable <code>divs</code> to be an object containing the children divs of <code>node</code> that exist when that line of code is run. Which it is, however it seems to update when a child is added to the parent node. What explains this behaviour; am I creating a reference to the element, and if so how do I achieve what I want to?</p>