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 Ctrl + F keys and search for “in operator”). So the in operator is old JavaScript feature wich exists beforeES5 (ECMAScript 2009)!!
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 and need some help with english syntax I recommend you this app Linguee dictionary and the related one DeepL translator.
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.
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: