JavaScript Syntax Soup: 「p in o」 vs 「for (p in o) {…}」

By Xah Lee. Date: . Last updated: .

Another episode of syntax soup.

JavaScript Syntax Soup: 「p in o」

In JavaScript, you have these syntax:

The first looks the same as part of the second, but they have nothing to do with each other. [see JavaScript: Access/List Properties]

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

Soup. Soup. It's All Good Soup.

Context Dependent Syntax

  1. JavaScript Syntax Soup: 「p in o」 vs 「for (p in o) {…}」
  2. Python's Context Dependent Syntax Soup: 「… in …」 And 「… not in …」
  3. Context Dependent Syntax, Lisp setf, Python a[i]=x

If you have a question, put $5 at patreon and message me.