You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Array.reduce function in an amp-bind expression currently only allows one parameter (the callback function) to be passed in. There should be support for the second parameter (initial value) as well.
One can prepend an initial value to an array before using the reduce function but having the second parameter is more ideal.
How do we reproduce the issue?
[1, 2, 3].reduce((x, y) => x + y) is OK. [1, 2, 3].reduce((x, y) => x + y, 0) is not accepted.
Hi there, I believe this along with operands limit on expressions, make it impossible or very hard to reduce into another array which is useful for state management of state/arrays.
dreamofabear
changed the title
Array.reduce function in amp-bind expression to support more than one parameter
amp-bind: Multiple args in closure functions e.g. reduce()
Jul 9, 2018
What's the issue?
The
Array.reduce
function in an amp-bind expression currently only allows one parameter (the callback function) to be passed in. There should be support for the second parameter (initial value) as well.One can prepend an initial value to an array before using the reduce function but having the second parameter is more ideal.
How do we reproduce the issue?
[1, 2, 3].reduce((x, y) => x + y)
is OK.[1, 2, 3].reduce((x, y) => x + y, 0)
is not accepted.What browsers are affected?
All browsers
Which AMP version is affected?
Latest.
CC: @jmarkoff & @sebastianbenz
The text was updated successfully, but these errors were encountered: