In today’s Ramón lesson Let’s learn data structures in JS! 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 (the link is an pdf archive where you will see it. You can open the pdf and hit
Related with the
in operator and objects properties you might like to read this interesting MDN Web Docs articles:
in operator, Object.hasOwn() and Optional chaining (?.).
P.S. For those who want to participate in the Class Central Forums and need some help with english syntax I recommend you this app Linguee dictionary and the related one DeepL translator.
Thank you so much, Carlos! This is fascinating!
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.
Nice mnemonic! in for index!
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().
And don’t use hasOwnProperty() anymore because as MDN have say:
Object.hasOwn() is intended as a replacement for
Everything that will help to remember what JS syntax means is helpful, so thank you for sharing Jane!!
Happy day and coding!
This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.