js快速将字符串数组转化为数字数组(互换)

1、数字数组转化为字符串数组

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

2、字符串数组转化为数字数组

var a = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
a.map(Number);  //结果:[1, 2, 3, 4, 5, 6, 7, 8, 9]
    原文作者:伟笑
    原文地址: https://blog.csdn.net/weixin_43045869/article/details/121783820
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞