Why if(key in null); throw exception while for(key in null); does not, it is the language design flaws on it?

Viewed 215

From a language design perspective, why:

if('k' in null);

TypeError: Cannot use 'in' operator to search for 'k' in null

BUT:

for('k' in null);

prints undefined

in ECMAScript spec:

Is it the language design flaw?

1 Answers
Related