Abstract
No API can or should attempt to be complete. Depending on the use-case, and the problem space, we often find that we may need to add, remove, or even constraint behavior to an object, or a type. Historically our approach to this was leveraging JavaScript’s dynamic nature, and simply tack on the additional behavior we wanted to see on any object. Symbols can help in this regard, by giving us the guarantee of collision-free keys. However, in many cases it can feel a tad hackish, especially when we do not wish to permanently modify behavior of an object for the lifetime of our application.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
- 2.
- 3.
Anyone remember eval??
- 4.
- 5.
- 6.
- 7.
- 8.
You can see this for yourself simply by using for(const m of Reflect.ownKeys(Reflect)) { console.log(m); } and comparing the list with the list found at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler .
- 9.
- 10.
- 11.
www.freeformatter.com/json-to-xml-converter.html
- 12.
Our DSL is heavily influenced by https://github.com/oozcitak/xmlbuilder-js/wiki .
- 13.
The elements array will be initialized with an empty object as its first entry.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2019 Raju Gandhi
About this chapter
Cite this chapter
Gandhi, R. (2019). Metamorphosis with Proxy and Reflect. In: JavaScript Next. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5394-6_13
Download citation
DOI: https://doi.org/10.1007/978-1-4842-5394-6_13
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-5393-9
Online ISBN: 978-1-4842-5394-6
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books