Created
September 25, 2015 02:00
-
-
Save dnasca/9689f0aecde0b1e9556e to your computer and use it in GitHub Desktop.
es6 - the death of the while loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//es5 | |
function repeat(func) { | |
while (func() !== undefined) { | |
} | |
} | |
//es6 proper tail call | |
function repeat(func) { | |
if (func() !== undefined) { | |
return repeat(func); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment