Using recursion combinators in JavaScript