-
Notifications
You must be signed in to change notification settings - Fork 16
Notes
Matt Huebert edited this page Feb 28, 2019
·
4 revisions
It's possible to implement ILookup
for "all" JavaScript objects, as explained by Mike Fikes here. This will only have an effect on plain objects whose prototype is js/Object
, not for any other kind of object (eg. it won't work for browser events or React components). It also mutates the global js/Object
.
How it's done:
Associative destructuring is based on get, which can be mapped onto goog.object/get for JavaScript objects by extending them to ILookup:
(extend-type object ILookup (-lookup ([o k] (goog.object/get o (name k))) ([o k not-found] (goog.object/get o (name k) not-found))))