mardi 27 octobre 2015

Object Reflection & Enumeration - JavaScript

I am currently reading "JavaScript The Good Parts" by Douglas Rockford and I came across the following two topics:

  1. Reflection
  2. Enumeration

According to the book:

It is easy to inspect an object to determine what properties it has by attempting to retrieve the properties and examining the values obtained.The typeof operator can be very helpful in determining the type of a property.

Although I understand what is being said, that we can use object reflection to basically view all the properties and values it contains. Something like reading ingredients from the back of product to see what is it exactly made of.

My Question is Why and How? Why would I need to use object Reflection, in what scenario and what are advantages of using it and How does Enumeration connect with? What is the link between Reflection & Enumeration?

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire