Question

Given a global variable exists that is defined and a variable notexists, what is an exhaustive list of where ReferenceErrors get thrown and don't get thrown? So far I have yes for:

notexists;
notexists++;

Also curious about special cases where they aren't thrown, e.g.:

var notexists = notexists; //equivalent to: var notexists; notexists = notexists;
typeof notexists; //special case?

Did I miss anything else?

Rationale: I'm writing a static analyzer and I have to cover all these cases perfectly.

Was it helpful?

Solution

Editing this answer to make the exhaustive list.

Yes:

notexists;
notexists++;
notexists.whatever;
void notexists;
notexists();

No:

notexists = exists;
var notexists = notexists;
typeof notexists;
delete notexists;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top