柯里化函数思想 :封装函数;
<script> function count(num1, num2) { return function calc(type) { switch (type) { case '+': return num1 + num2 case '-': return num1 - num2 case '*': return num1 * num2 case '/': return num1 / num2 } } } const newCount = count(100, 10) // console.log(count(100, 10)('*')) console.log(newCount('+')) //110 console.log(newCount('-')) //03-柯里化函数.html:28 90 console.log(newCount('*')) //03-柯里化函数.html:29 1000 console.log(newCount('/')) //03-柯里化函数.html:30 10 </script>