# About the "in" operator

**URL:** <https://group.classcentral.com/t/about-the-in-operator/35845>\
**Category:** JavaScript Bootcamp\
**Created:** [September 27, 2022, 10:22am UTC](https://group.classcentral.com/t/about-the-in-operator/35845 "2022-09-27T10:22:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlost2672543](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/carlost2672543/32/4162_2.png) [@carlost2672543](https://group.classcentral.com/u/carlost2672543)\
**Post date:** [September 27, 2022, 10:22am UTC](https://group.classcentral.com/t/about-the-in-operator/35845/1 "2022-09-27T10:22:09Z")

</div>

Hi everyone!!

In today’s Ramón lesson [Let’s learn data structures in JS!](https://www.classcentral.com/cohort/js-bootcamp-fall-2022/events/184) someone have asked if the `in` operator was a `ES6` featured and we were not sure about it, probably ES5 I have said.

Correcting myself here: well I have found the `in` operator in the second edition ( **August 1998** ) of the [_ECMA-262 Standard_](https://www.ecma-international.org/wp-content/uploads/ECMA-262_2nd_edition_august_1998.pdf) (the link is an pdf archive where you will see it. You can open the pdf and hit `Ctrl + F` keys and search for “in operator”). So the in operator is old JavaScript feature wich exists **before**  **ES5** (_ECMAScript 2009_)!!

Related with the `in` operator and objects properties you might like to read this interesting [_MDN Web Docs_](https://developer.mozilla.org/en-US/) articles: [`in` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in), [Object.hasOwn()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn) and [Optional chaining (?.)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining).

I hope this is of interest to you and has help you on your way to achieve excellence in JavaScript.

**P.S.** For those who want to participate in the [Class Central Forums](https://group.classcentral.com/) and need some help with english syntax I recommend you this app [Linguee](https://www.linguee.com/) dictionary and the related one [DeepL translator](https://www.deepl.com/translator). 😄

---

<div class="post-metadata">

**Author:** ![hola\_soy\_milk](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/hola_soy_milk/32/600_2.png) [@hola\_soy\_milk](https://group.classcentral.com/u/hola_soy_milk)\
**Post date:** [September 27, 2022, 8:02pm UTC](https://group.classcentral.com/t/about-the-in-operator/35845/2 "2022-09-27T20:02:09Z")

</div>

Thank you so much, Carlos! This is fascinating!

---

<div class="post-metadata">

**Author:** ![Jane2963637](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/jane2963637/32/6117_2.png) [@Jane2963637](https://group.classcentral.com/u/Jane2963637)\
**Post date:** [September 28, 2022, 1:02am UTC](https://group.classcentral.com/t/about-the-in-operator/35845/3 "2022-09-28T01:02:44Z")

</div>

I was wondering, based on what was said in the Q and A today about the difference between for (let… in…) and for (let… of…), maybe thinking of “in” as standing for “index” would be helpful. I’m not sure if this is stating the obvious. 🙂

---

<div class="post-metadata">

**Author:** ![syllie](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/syllie/32/6257_2.png) [@syllie](https://group.classcentral.com/u/syllie)\
**Post date:** [September 28, 2022, 6:41am UTC](https://group.classcentral.com/t/about-the-in-operator/35845/4 "2022-09-28T06:41:13Z")

</div>

Nice mnemonic! 🧠 🤓 in for index!

---

<div class="post-metadata">

**Author:** ![carlost2672543](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/carlost2672543/32/4162_2.png) [@carlost2672543](https://group.classcentral.com/u/carlost2672543)\
**Post date:** [September 28, 2022, 8:29am UTC](https://group.classcentral.com/t/about-the-in-operator/35845/5 "2022-09-28T08:29:34Z")

</div>

Yeah @Jane2963637

Anything it works to remember it.

I think on it like this _Are you IN this Barcelona JS Club or IN the original (prototype) Providence JS?_, for example. Because `in` it checks if that property is an own property or inherited one from its prototype.

For check ONLY the own properties you have this method: [Object.hasOwn()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn).

And don’t use hasOwnProperty() anymore because as MDN have say:

> **Note:** `Object.hasOwn()` is intended as a replacement for [`Object.hasOwnProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty).

Everything that will help to remember what JS syntax means is helpful, so thank you for sharing Jane!!

Happy day and coding!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/ccstudygroup/original/1X/36206832181ed26910a18e33d8bfef087cf661b1.svg) [@system](https://group.classcentral.com/u/system)\
**Post date:** [November 12, 2022, 8:30am UTC](https://group.classcentral.com/t/about-the-in-operator/35845/6 "2022-11-12T08:30:04Z")

</div>

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.
