Using destructuring for function arguments

Kevin Smith zenparsing at gmail.com
Sat May 31 14:13:42 PDT 2014


Or, for more readable code:

    function setCookie(name, value, options = {}) {

        let {

            secure = false,
            path = "",
            domain = "",
            expires = whenever()

        } = options;

        // Do stuff

    }

Kevin

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140531/710fe20c/attachment.html>


More information about the es-discuss mailing list