如何在 JavaScript 中将整数数组转换为字符串数组?
要将整数数组转换成字符串数组,在 JavaScript 中使用 map(String)。假设以下为我们的整数数组 −
var integerValues = [101,50,70,90,110,90,94,68];
将整数数组转换成字符串数组 −
integerValues.map(String);
示例
以下是代码 −
var integerValues = [101,50,70,90,110,90,94,68];
console.log("The integer array value=");
console.log(integerValues);
integerValues.map(String);
console.log("The string array value=");
console.log(integerValues)要运行以上程序,你需要使用以下命令 −
node fileName.js.
这里,我的文件名是 demo212.js。
输出
控制台中的输出如下 −
PS C:\Users\Amit\JavaScript-code> node demo212.js The integer array value= [ 101, 50, 70, 90, 110, 90, 94, 68 ] The string array value= [ 101, 50, 70, 90, 110, 90, 94, 68 ]
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP