문제

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.

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top