我有一个数字数组,例如 [7,8,9,10]。我需要将每个数组元素作为单个数字变为 07、08、09 等。
有什么想法吗?
最佳答案
最简单最基本的方法:
var index;
var a = [7, 8, 9,10];
for (index = 0; index < a.length; ++index) {
if(a[index]>0 && a[index]<10)
alert((0).toString()+a[index].toString());
else
alert(a[index])
}
关于Javascript:如何将数组元素从 7、8、9、10 编辑为 07、08、09、10?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36988783/