Node.js 在数组数据中插入字符

Node.js 在数组数据中插入字符,node.js,typescript,Node.js,Typescript,如何从数组中插入字符 这是我的数据: ["a", "b", "c", ...] 我想这样更改我的数据: ["$a", "$b", "$c", ...] 感谢您使用map-ES6方式 const arr=['a','b'] 常量modifiedArray=arr.map(el=>“$”+el) console.log(modifiedArray) 映射基本上遍历数组并根据给定条件映射每个元素 Array.map(value=>在这里用任何类型的数据映射值),const newArray=[

如何从数组中插入字符

这是我的数据:

["a", "b", "c", ...]
我想这样更改我的数据:

["$a", "$b", "$c", ...]

感谢您使用
map
-ES6方式

const arr=['a','b']
常量modifiedArray=arr.map(el=>“$”+el)
console.log(modifiedArray)
映射基本上遍历数组并根据给定条件映射每个元素


Array.map(value=>在这里用任何类型的数据映射值)

,const newArray=[“a”、“b”、“c”、…]map(item=>“$”+item);Imho该参数应命名为
(或至少不是
)。“键”是第二个参数的索引。
let a = ["a", "b", "c", ...]
a.map(value => '$'+value) // this will do what you need returns ["$a", "$b", "$c"]