Discuss / JavaScript / 字符串数组转整数数组、字符串转整数、首字母大写

字符串数组转整数数组、字符串转整数、首字母大写

Topic source

字符串数组转整数数组 arr.map(Number); arr.map(x => parseInt(x));

字符串转整数 function string2int(s) { //return s.split('').map(x => x - '0') return Array.prototype.map.call(s, x => x - '0') .reduce((x,y) => x * 10 + y) }

首字母大写 function normalize(arr) { return arr.map(x => ${x[0].toUpperCase()}${x.slice(1).toLowerCase()}) }

归帆未至

#2 Created at ... [Delete] [Delete and Lock User]

字符串数组转整数数组为什么不能直接用parseInt,要x => parseInt(x)啊?


  • 1

Reply