本文介绍了join方法不适用于数组JAVASCRIPT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了这个代码,我绘制了一个数组,但今天我将解释这个代码是什么,因为问题是另一个。
我运行一个处理del'arrayelaborazione,问题是当我想删除逗号时,使用join方法不起作用,文本仍然是逗号,怎么可能?这段代码有什么问题?

I created this code that I draw an array, but today I'll explain what is this code because the problem is another.I run a processing del'array "elaborazione", the problem is that when I want to remove the commas, using the join method does not work, the text remains the commas, how is it possible? What is wrong with this code?

for (i = 0; i < count; i++)
{
   var opt = new Option();
   var elaborazione = v[i].split(";");
   elaborazione.splice(2,2);
   elaborazione.join(" ");
   alert("elaborazione => " + elaborazione);
   opt.innerHTML = elaborazione;
   select.add(opt);
}


推荐答案

您需要将加入的字符串保存在 elaborazione 变量中。

You need to save the joined string in elaborazione variable.

使用

elaborazione = elaborazione.join(" ");

这篇关于join方法不适用于数组JAVASCRIPT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 05:11