Discuss / JavaScript / 尽量不使用自带函数的解法

尽量不使用自带函数的解法

Topic source

猎杀属性

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

字符串转数字

function string2int(s) { return Array.prototype.map .call(s, x => { return 1 * x; }) .reduce((x, y) => { return x * 10 + y; }); }

格式化名字

function normalize(arr) { return arr.map(v => { return Array.prototype.map .call(v, (x, i) => { if (i === 0) { x = x.toUpperCase(); } else { x = x.toLowerCase(); } return x; }) .reduce((x, y) => { return x + y; }); }); }


  • 1

Reply