// 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; }