Default parameter value undefined; is this a JavaScript Bug?
问题 Below is a syntactically valid javascript program – only, it doesn't behave quite the way we're expecting. The title of the question should help your eyes zoom to The Problem Area const recur = (...args) => ({ type: recur, args }) const loop = f => { let acc = f () while (acc.type === recur) acc = f (...acc.args) return acc } const repeat = n => f => x => loop ((n = n, f = f, x = x) => // The Problem Area n === 0 ? x : recur (n - 1, f, f (x))) console.time ('loop/recur') console.log (repeat