Change x == null to typeof x == 'undefined'