开发者

array join() method without a separator

开发者 https://www.devze.com 2022-12-17 18:21 出处:网络
var arr= [\'g\',\'o\',\'o\',\'d\']; var arr2 = arr.join(); Arr2 will be "g,o,o,d". I would like to get "good". I know there 开发者_如何学Goare a million other ways to achieve this
var arr= ['g','o','o','d'];
var arr2 = arr.join();

Arr2 will be "g,o,o,d". I would like to get "good". I know there 开发者_如何学Goare a million other ways to achieve this but was curious if there was a way with join.


Sure - just pass an empty string:

var arr2 = arr.join('');
0

精彩评论

暂无评论...
验证码 换一张
取 消