title: Is array[index] === undefined the always same as typeof array[index] === 'undefined'?
body: <p>I need to see whether something there is an entry for an array index in Javascript and <a href="https://stackoverflow.com/questions/13107855/how-to-check-if-array-element-exists-or-not-in-javascript">this answer</a> say to uses (Essentially I changed it from === to !==):</p>
  
  <blockquote>
    <p>if(typeof arrayName[index] !== 'undefined') </p>
  </blockquote>
  
  <p>IIUC this is the same as `arrayName[index] !== 'undefined'?</p>
  
  <p>I experimented with it and it works, but I want to make sure I'm not missing any edge cases?</p>
  
  <h2>Update</h2>
  
  <p>To clearify WRT to some answers given (Ran this on node <code>9.11.2</code>):</p>
  
  <pre><code>    let undefined = "Hello";
      console.log(undefined);
      let arrayName = [];
      if(arrayName[0] !== undefined) {
          console.log("Test passes");
          console.log("undefined is: ", undefined);
          console.log("arrayName[0] is: ", arrayName[0]);
      }
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>Hello
  Test passes
  undefined is:  Hello
  arrayName[0] is:  undefined
  </code></pre>
  
  <p>So it seems the answer is "No undefined could sometimes be redefind ..." ... and it's better to stick with <code>typeof array[index] === 'undefined'</code>, but as some have indicated, undefined cannot be redefined globally, so it should be fairly safe to use the shorter version.</p>