1. Convert a string to an array:
let str ='1326814250918531073,1326814250918531074,1326814250918531075';
let arr = str.split(',')
console.log(arr)
// 结果: ["1326814250918531073", "1326814250918531074", "1326814250918531075"]
2. Transfer the characters in the array to numeric types:
let str ='1326814250918531073,1326814250918531074,1326814250918531075';
let arr = str.split(',').map((item) => item * 1)
console.log(arr)
// 结果: [1326814250918531000, 1326814250918531000, 1326814250918531000]
3. Convert the array to a string:
let arr = [1326814250918531000, 1326814250918531000, 1326814250918531000]
function arrToString(arr) {
let str = []
arr.forEach((ele) => {
str.push(ele)
})
return str.join(',')
}
console.log(arrToString(arr))
// 结果: 1326814250918531000,1326814250918531000,1326814250918531000
Record, copy and use it next time, it's convenient _