Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is ES6 dynamic object property or plain bracket notation being used here?

In this video around 16:00 the instructor says dynamic object property syntax is being used (total[language]). It seems like it’s just regular setting a property on an object using a variable, which here is (destructured from the repo object, the current item being iterated over in the reduce method) language. Did he make a mistake calling it a dynamic object property or am I missing something?
enter image description here

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The reason why they called it a dynamic property is because from the perspective of the total object – the language variable that is being passed in as a key can contain any value during the application runtime, hence hypothetically any property can be accessed at different runs – making it dynamic.

So the instructor was correct, even though there is no other official term for using a variable as a property accessor.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading