Skip to content

Instantly share code, notes, and snippets.

View hsuan1117's full-sized avatar
🥰

Hsuan hsuan1117

🥰
View GitHub Profile
@hsuan1117
hsuan1117 / sum.js
Created May 1, 2020 13:07 — forked from FlandreDaisuki/sum.js
應該是最美的 currying sum
// ref: https://t.me/JavaScriptTw/52631
function sum(...args) {
const total = args.reduce((p, c) => p + c);
const sumFunc = sum.bind(null, total);
sumFunc.valueOf = () => total;
return sumFunc;
}