Reduce, Reuse, React — JavaScript January

  • Briefly, it takes two arrays: (the string constants ) and (the templated string values that need to be encoded ).
  • It is passed an array of strings, but what I’m calling an array of values, is actually a variable number of arguments.
  • I’m using ES6 “rest” syntax to convert the arguments into an array of values.
  • When we reduce over strings, the zeroth element of the strings array is passed as partialUri and iteration starts with the first element, and so on.
  • It’s a special form of the ES6 template literal that we used above, but it allows us to process it with a function.

A while back while writing a React application that hit a REST endpoint, I wrote a little utility to build a properly encoded Uri path. At the time, I didn’t think much about it. It did the job and I moved on.
Continue reading “Reduce, Reuse, React — JavaScript January”