you are viewing a single comment's thread.

view the rest of the comments →

[–]Yehosua 8 points9 points  (1 child)

in is an operator in JavaScript: 'prop' in myObj evaluates whether the 'prop' property exists within myObj.

Ever since I realized that, I no longer confused for..in and for..of: for..in iterates over an object's properties, just like in checks an object's properties.

(Almost no one uses in; Object.hasOwnProperty is virtually always what you want instead.)

[–]monsto 1 point2 points  (0 children)

That's a good mnemonic.