JavaScript Context Dependent Semantics: p in o

By Xah Lee. Date: . Last updated: .

In JavaScript, you have these syntax:

p in o
check if property exist. 〔see JS: in (operator) 👎〕
for (p in o) {…}
enumerate properties. 〔see JS: for-in Loop 👎〕

Both contains p in o, but their meaning is very different.

In other words, the in operator has context dependent semantics.

Context Dependent Semantics