var old_response = ["a,b,c","x,y,z","e,f,g"]
new_response = ["a,b,c,x,y,z,e,f,g"]
目前我得到old_response
而不是我需要new_response
只需使用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()])
您可以将数组转换为字符串:
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)