jshint/jshint — Issue #433: Spurious warning about != vs. !== use
Author: oaubert
Created: 2012-02-02 15:12:17+00:00
State: open

When testing the existence of an optional parameter, I use the following common pattern:

if (typeof foo != 'undefined') {
// The foo parameter is defined...
}

This code raises a warning in jshint: Expected '!==' and instead saw '!='.
This warning is spurious: the typeof function always returns a string, so in this case,
typeof foo != 'undefined' is as valid as typeof foo !== 'undefined'.

Given that the "typeof ... != 'undefined'" pattern is common, it maybe should be taken into account?