Why if('k' in 42); throw exception while for('k' in 42); does not, in javascript?

Viewed 237

From a language design perspective, why does

if ('k' in 42);

throw a TypeError exception while

for ('k' in 42);

does not?

I've read the following sections in ECMAScript spec:

Can someone explain the rationale in having such an inconsistency?

Why can't expression 'k' in 42 in if (...) just evaluate to false?

2 Answers
Related