In Python, you can call the string.join()
method on any iterable, like so:
",".join(some_iterable)
The argument may be a list, generator, or any other object as long as it is iterable.
Playing around with ES6, I couldn't find a way to do so without having to create an array first, I had to do something like this:
function *myGenerator() { ... }
let output = [...myGenerator()].join(",");
I know that join()
is an Array.prototype
method. Is it possible for me to call join()
or some equivalent to concatenate the values generated by myGenerator
without having to create an intermediate array, like the python example above?