Setting up (non-index) properties of arrays

Axel Rauschmayer axel at rauschma.de
Sat Aug 4 00:06:10 PDT 2012


As an example, a template string call site ID would be constructed as follows:

    const callSiteId1234 = do {
        let literalParts = ['lit1\n', ' lit2 ', ''];
        literalParts.raw = ['lit1\\n', ' lit2 ', ''];
        literalParts
    };

How about the following abbreviation?

    const callSiteId1234 = ['lit1\n', ' lit2 ', '', raw: ['lit1\\n', ' lit2 ', '']];

Not sure it’s a frequent-enough use case, though. Mustache would be nice here, or one could use Underscore:

    const callSiteId1234 = _.extend(['lit1\n', ' lit2 ', ''], {raw: ['lit1\\n', ' lit2 ', '']});

-- 
Axel Rauschmayer

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


More information about the es-discuss mailing list