为什么在 jquery 中对数组使用 map(内爆)时使用双引号?

Why double quotes when using map (imploding) for an array in jquery?

我有一个要转换成字符串的数组

100
110
120
145

我想要这个 result/output:

"100","110","120","145"

我试过了:

var send_data_ids = $.map( ids_above, function( n ) {
    return String.fromCharCode(34) + n + String.fromCharCode(34);
});

但是我得到了双引号。为什么?

""100"",""110"",""120"",""145""

$.map 将 return 另一个数组,如果你想要一个字符串,只需使用:

var x = ["100","110","120","145"];
var y = "\""+x.join("\",\"")+"\"";

或在您的代码中执行

var send_data_ids = $.map( ids_above, function( n ) {
    return String.fromCharCode(34) + n + String.fromCharCode(34);
});
var y = "\""+send_data_ids.join(",")+"\"";