Is there a way to join the elements in an js array, but let the last separator be different?

前端 未结 11 800
灰色年华
灰色年华 2021-02-03 17:40

What I want is something like Array.join(separator), but which takes a second argument Array.join(separator, beforeLastElement), so when I say [f

11条回答
  •  心在旅途
    2021-02-03 18:15

    No, this is specific enough that you will have to write a custom function. The good news is, as you said, once you use Array.join to take care of all the separators, the last one will be easy enough to update.

提交回复
热议问题