typeof obj === 'undefined' vs obj === undefined

Edit on GitHub

Setup

obj = {};
i = 0;

Tests

  • typeof obj === 'undefined'

    if(typeof obj === 'undefined')
       i++;
  • obj === undefined

    if(obj === undefined)
       i++;