How to inject protected methods in JavaScript - Part II
As a performances maniac, I've found another way to inject protected methods, or something similar, without unnecessary overload of each public method. Of course, precedent way is definitively more clear, linear, but if you have a constructor.prototype with a lot of private methods, the overload process will be a wall in front of method execution speed. Each time you will use a public method, you have to set, and unset, every protected method, and at the same time, as explained in my precedent post, you cannot send the object outside during public method execution, because it will expose every method, protected included. This new proposal is based on a Function like strategy, applied to instances: apply, and call. Please have a look at this prototype function: function prototype(constructor, public, protected){ // webreflection - mit style if(protected){ public.apply = function(callback, arguments){ return (callback.charAt(0) === "_" ? protected : this)[callback]....