I have 2 javascript code. Bothe of them check if varable equal to null or type of variable is undefined. But in one condition I get error and in other I don't get any error.
Code 1:
if (NS1 === null || typeof (NS1) === 'undefined') {
    ...  }
Code 2:
 if (window.NS1 === null || typeof (window.NS1) === 'undefined') {
  ...   }
For code 1 I get error
NS1 is not defined
while for code 2 I don't get any error. I don't understand what might be the reason as i have not defined NS1 or window.NS1 . So I should get error in both the condition.
 
     
    