js字符数组转化为数字数组

['1','2','3'] => [1,2,3]

['1','2','3'].map(Number) // [1,2,3]

['1','2','3'].map((value)=>{ return parseInt(value) }) // [1,2,3] JSON.parse('[' + String(['1', '2', '3']) + ']') // [1,2,3] eval('[' + String(['1', '2', '3']) + ']') // [1,2,3]

猜你喜欢

转载自www.cnblogs.com/lhqdbk/p/11573334.html
今日推荐