Implement Spread Operator

Description

The Spread operator is super convenient in the JavaScript world and would be a great addition to the modern trend of functions/syntaxes being adopted by cfscript.

I would suggest implementing it in the same way as JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax

The return from a spread operation would be a new array or struct containing the items that were spread out. Would allow for much cleaner functional programming style where avoiding mutating data is key.

Merging objects is one use case:

Merging arrays:

Oh, and another, converting a string into array:

As a side effect, this could eliminate the need to do things like

and instead you'd be able to do

Not the only use case (see link above), but one that I run into frequently and wish I had a spread operator.

Activity

Show:
Sebastian Zartner
October 27, 2020, 9:34 PM

The spread operator makes different use cases very convenient to write, so a big from me.

Sebastian

Assignee

Unassigned

Reporter

Abram Adams

Labels

None

Priority

New
Configure