数组里的字符串转换成数字或者把数字转换成字符串 【1,2,3】==【"1","2","3"】

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]

 

 

 

 

 

感谢https://www.cnblogs.com/web-record/p/10208485.html

posted @ 2021-05-26 12:01  小白呀白菜  阅读(257)  评论(0编辑  收藏  举报