ES6 immediately invoke recursive arrow function
问题 This is my current code: const fn = parameter => { // if, else ... fn(X); }; fn(0); Now, I can't use this approach as I need to call the function with a parameter and it must be callable recursively. How to refactor the above arrow function to be immediately invoked and recursively callable? 回答1: First, let me put the disclaimer that Immediately-Invoked-Function-Expressions (IIFE) are considered bad practice in ES6, and this is tail-recursion and personally I would change it to a for loop.