title: How to catch array index out of bound in JavaScript?
body: <p>I want to catch an error when access outside of array's bounds happens but it doesn't seem to throw an error.</p>
  
  <pre><code>let arr = [2,4,5];
  let test = arr[3];
  console.log(test);
  </code></pre>
  
  <p>I know that I can test for undefined and throw an error</p>
  
  <pre><code>if (arr[3] === undefined) throw new Error();
  </code></pre>
  
  <p>but how come I can't just do try and catch it like the following.</p>
  
  <pre><code>let arr = [2,4,5];
  try {
        let tmp = arr[3];
      } catch(e) {
        lastIndex = findLastIndex(arr, high / 2, high);
        break;
      }
  </code></pre>