Preferences = {
XDPI:90,
YDPI:90,
*:function(missing_name) {"Tell Joe he forgot to implement " + missing_name+ " property or func"}
}
Say I got an old/undocumented/minified/uglified class I want to replace with my own implementation. How could I catch all the old properties that could be missing from within my new "object" ?.
(Say there are a lot of client script (macros) used by non-technical users. I want to ease the report of missing func)
E.g if a script call Preferences.CurrentPrinter I want the Preferences object to diagnose it lacks a CurrentPrinter property without the user having to look at the console
Sixth edition of ECMAScript specification introduces Proxy objects for that purpose:
http://www.ecma-international.org/ecma-262/6.0/#sec-proxy-objects
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
But this is not widely supported yet. At the moment of writting this, only Edge and Firefox browsers do that:
http://caniuse.com/#feat=proxy
P.S. Lucky you if you read that in future and all browsers already support that :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With