title: How can I remove all but the last N elements from an array?
body: <p>I have an array. I have a variable that shows how many elements in the array must be left at the end. Is there a function that would do that? Example:</p>
  
  <pre><code>var arr = [1, 2, 3, 4, 5];
  var n = 2;
  arr = someFunction(n); // arr = [4, 5];
  </code></pre>
  
  <p>I want an array with the last <code>n</code> elements in it.</p>