如何将数字数组连接到1个串联的数字中? [英] How can I join an array of numbers into 1 concatenated number?
本文介绍了如何将数字数组连接到1个串联的数字中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何加入该数组以尽可能少的步骤为我提供预期的输出?
How do I join this array to give me expected output in as few steps as possible?
var x = [31,31,3,1]
//expected output: x = 313131;
推荐答案
使用数组join
方法.Join
将数组的元素连接成字符串,然后返回该字符串.默认的分隔符是逗号(,).这里的分隔符应该是一个空字符串.
Use array join
method.Join
joins the elements of an array into a string, and returns the string. The default separator is comma (,). Here the separator should be an empty string.
var x = [31,31,3,1].join("");
这篇关于如何将数字数组连接到1个串联的数字中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文