How it works...

As mentioned before, the local Symbol instances will be unique every time they are created. Thus, we aren't able to recreate the Symbol value in the main function. This means that any code expecting a value from that enum can't be coerced with an equivalent value.

One use in which enum types are valuable is as options. Imagine an options object, one of the options needs to be able to take multiple values (say animation tweening). A string value would get the job done but can easily be miss-typed. With an enum, the user of a function must reference that enum; this is less brittle and clearer when reading afterward.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.185.15