[PROPOSAL] "use" keyword

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Jul 25 13:33:27 PDT 2014


the method knows shared as soon as you define it inside your closure ...


```
var lib;

(function () {
    var shared;

    shared = 'a shared value';

    function wrap(method) {
      return function () {
        var args = [].slice.call(arguments);
        args[0] = shared;
        return method.aply(this, args);
      };
    }

    lib = {
        method: function method(foreignObject) {
            var property;

            for (property in foreignObject) {
                if (foreignObject.hasOwnProperty('property')) {
                    if (typeof foreignObject[property] === 'function') {
                        foreignObject[property]
= wrap(foreignObject[property]);
                    }
                }
            }
        }
    };
}());

```

... take care ...



On Fri, Jul 25, 2014 at 1:25 PM, Michaël Rouges <michael.rouges at gmail.com>
wrote:

> @Andrea :
>
> Yeah, I don't really want to rewrite the methods, I only want to share my
> "shared" variable with these methods.
>
> Furthermore, your code don't works because "method" don't knows "shared".
>
>
>
> Michaël Rouges - https://github.com/Lcfvs - @Lcfvs
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140725/f185b1b5/attachment.html>


More information about the es-discuss mailing list