简体   繁体   English

从JavaScript中的数组中删除双引号

[英]Remove double quotes from an array in JavaScript

var old_response = ["a,b,c","x,y,z","e,f,g"] 
new_response = ["a,b,c,x,y,z,e,f,g"]

Currently I am getting the old_response instead of that I need new_response 目前我正在获得old_response而不是我需要new_response

Simply join the elements using Array#join method and put into a new array. 只需使用Array#join方法连接元素,然后将其放入新数组。

 var old_response = ["a,b,c","x,y,z","e,f,g"] ; var new_response = [old_response.join()]; console.log(new_response); 

 old_response = ["a,b,c","x,y,z","e,f,g"] console.log([old_response.join()]) 

You could cast your array to string: 您可以将数组转换为字符串:

 var old_response = ["a,b,c","x,y,z","e,f,g"] var new_response = [old_response.toString()] // or [old_response + ''] console.log(new_response) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM