JS 将数字字符串数组转为 数字数组 (互换)

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
arr.map(String);  //结果: ['1', '2', '3', '4', '5', '6', '7', '8', '9']


var a = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
a.map(Number);  //结果:[1, 2, 3, 4, 5, 6, 7, 8, 9]

 

posted @ 2019-10-08 17:35  敲代码的树先生  阅读(10059)  评论(0编辑  收藏  举报