Javascript 没有分隔符的数组 join() 方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2125779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-22 22:50:57  来源:igfitidea点击:

array join() method without a separator

javascript

提问by Adrian Adkison

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 are a million other ways to achieve this but was curious if there was a way with join.

Arr2 将是“g,o,o,d”。我想得到“好”。我知道还有一百万种其他方法可以实现这一点,但很好奇是否有加入的方法。

Thanks

谢谢

回答by Shog9

Sure - just pass an empty string:

当然 - 只需传递一个空字符串:

var arr2 = arr.join('');