在字符串变量中接收 MAP

Receive MAP in a string variable

我想知道如何将变量列表设置为字符串。

const emails = [
  {"ID": "11109", "VALUE": "financesss@123m.com", "TYPE_ID": "EMAIL"},
  {"ID": "13429", "VALUE": "teste@testeeeee.com", "TYPE_ID": "EMAIL"}];

const list = emails.map(VALUE => VALUE.VALUE)

console.log(list) //desired result:: financesss@123m.com,teste@testeeeee.com
console.log(typeof list); //string

您可以使用分隔符将数组连接成单个字符串,方法是

const list = emails.map(VALUE => VALUE.VALUE).join(",");

join 的默认分隔符是逗号 (,),因此您可以根据需要将其表示为 arr.join()

请参阅此处了解 join 的定义:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join