I had an object with 218 attributes that i set and I wanted to loop through all of them and I thought I would have to *make* an array of all the attribute names. You saved me so much time. Thank you.
I experimented with adding named properties to array objects and they are enumerated with the for-in loop. The inbuilt .length property is not (and ar.propertyIsEnumerable("length") returns false). I attempted to set the .length property's enumerable attribute to true (using ar.length.enumerable = true;). When I checked its enumerability with ar.propertyIsEnumerable("length"), the return value is true. However, when I repeated the for-in loop on the array, the length property was ignored. I remain confused by this and would appreciate any insight.
You can't change the attribute of a property using this technique. You need to use Object.defineProperty(). However, the configurable attribute of the length property is set to false. This means you can't make any changes to its attributes. I hope that helps.
A Great Javascript Channel. Thank you for your efforts. May God Bless You.
simple beautiful and in-depth. You're doing a great service thank you!
I had an object with 218 attributes that i set and I wanted to loop through all of them and I thought I would have to *make* an array of all the attribute names. You saved me so much time. Thank you.
Thank you so much for this video! I was stuck on some "for in loop" challenge questions @ school and this video helped me solve the questions.
Great to hear! Thanks for the feedback.
your videos are really unique, thankyou steven :) .
Thank you for the teaching. I learnt a lot from it.
Thanks, very clear explanation.
Extremely helpful, thank you!
I experimented with adding named properties to array objects and they are enumerated with the for-in loop. The inbuilt .length property is not (and ar.propertyIsEnumerable("length") returns false). I attempted to set the .length property's enumerable attribute to true (using ar.length.enumerable = true;). When I checked its enumerability with ar.propertyIsEnumerable("length"), the return value is true. However, when I repeated the for-in loop on the array, the length property was ignored. I remain confused by this and would appreciate any insight.
You can't change the attribute of a property using this technique. You need to use Object.defineProperty(). However, the configurable attribute of the length property is set to false. This means you can't make any changes to its attributes. I hope that helps.