title: Javascript array referencing an array position (not an element)
body: <p>UPDATE:</p>
  
  <p>Many asked why not using <code>[arr[0], arr[1]]</code>. The problem is I have to pass this array to a method, which I don't have access <a href="https://material.angular.io/components/table" rel="noreferrer">Angular Material Table</a>. And I don't want to call the method over and over again. </p>
  
  <p>I already processed the <code>arr</code> array and I don't want to process <code>pointer</code> array to reflect the new data, which I already know where it is.</p>
  
  <p>The <a href="https://stackoverflow.com/a/53991321/8038345">Nina Scholz answer</a> seems to solve the problem.</p>
  
  <hr>
  
  <p>Is there a way to use "pointers" like C in Javascript?</p>
  
  <p>What I want to do is:</p>
  
  <p>I have an array with objects</p>
  
  <pre><code>const arr = [
      {prop: 3},
      {prop: 4},
  ];
  </code></pre>
  
  <p>And I want to have an array to point to the positions of this array</p>
  
  <pre><code>const pointer = [arr[0], arr[1]]; // I want pointer to point to be an array containing the first and second elements of arr
  </code></pre>
  
  <p>This will get a reference to the <code>{prop: 3}</code> and <code>{prop: 4}</code> objects, which is not what I want, because, if I do:</p>
  
  <pre><code>arr.splice(0, 0, {prop: 1}); // arr =&gt; [{prop:1},{prop:3},{prop:4}]
  console.log(pointer); // [{prop: 3},{prop: 4}]
  </code></pre>
  
  <p>As you can see, <code>pointer</code> holds a reference to the objects <code>{prop:3}</code> and <code>{prop:4}</code>.</p>
  
  <p>How can I achieve <code>pointer</code> to hold reference to the position 0 of the array, instead of the object stored in it? So, on this example, <code>pointer =&gt; [{prop:1},{prop:3}]</code>?</p>
  
  <p>I can't call <code>pointer = [arr[0], arr[1]]</code> all the time because <code>arr</code> will change constantly and asynchronously.</p>
  
  <p>Is there a "reactive" way to handle arrays?</p>