2

I really don't get why Visual Studio gives me the warning "Qualifier can be 'null' or 'undefined'" on the execution of "ra.split('')" below, even after I did a nullity check. I have this code:

var ra = data.RiskAnalysis;
if (typeof ra !== "undefined") {
    var ebwg = ra.split('');
}

As you can read in this stackoverflow-post 'typeof ra' would return 'object' if the value was null.

Is this a bug? Or isn't my check sufficient?

Community
  • 1
  • 1
Gigi2m02
  • 1,238
  • 3
  • 17
  • 33

1 Answers1

5

Okay, that was a stupid question. Ofcourse is the warning correct: If ra is equal to 'null' the if statement allows to go further because 'object' isn't equal to 'undefined'. Changed code to this:

if (typeof ra !== "undefined" && ra != null)
Gigi2m02
  • 1,238
  • 3
  • 17
  • 33