`const` function arguments and object property shorthand

Alexander Jones alex at weej.com
Thu May 14 20:16:49 UTC 2015


    function(const foo, const bar) {

        const foo: bar

Such that the names foo and bar are not assignable in the function body or
as an object property - such assignment would ideally have identical
behaviour to assigning to a const variable, i.e. a SyntaxError, although in
the object case, as the 'constness' is not statically determinable, so I
think this would have to just behave like a non writable property, or throw
a runtime error instead.

Possible equivalence to:

    function(foo_, bar_) {
        const foo = foo_;
        const bar = bar_;

    Object.create(Object.prototype, {
        foo: {enumerable: true},

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/b2da6052/attachment-0001.html>

More information about the es-discuss mailing list