Dùng map(String) để chuyển từng phần tử sang chuỗi.
Mã thực hiện
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);
Kết quả
The integer array value= [ 101, 50, 70, 90, 110, 90, 94, 68 ] The string array value= [ 101, 50, 70, 90, 110, 90, 94, 68 ]
Lưu ý: map(String) không thay đổi mảng gốc, cần gán lại: integerValues = integerValues.map(String).