JavaScript Context Dependent Semantics: p in o
In JavaScript, you have these syntax:
p in o
- check if property exist. [see JavaScript: “in” Operator]
for (p in o) {…}
- enumerate properties. [see JavaScript: for-in Loop]
Both contains
p in o
,
but their meaning is very different.
In other words, the in
operator has context dependent semantics.