Skip to content

Instantly share code, notes, and snippets.

@ymyzk
Created Jun 20, 2016
Embed
What would you like to do?
Simple example of proper tail calls in ECMAScript 2015
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Proper Tail Calls</title>
</head>
<body>
<h1>Example of Proper Tail Calls</h1>
<p>
Please open console. If your web browser supports proper tail calls, it shows "It works!".
</p>
<script>
"use strict";
function f(n){
if (n <= 0) {
return "It works!";
}
return f(n - 1);
}
console.log(f(1000000));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment