Syntax
- only return call() either implicitly such as in arrow function or explicitly, can be a tail call statment
- function foo(){
return bar();
} // the call to bar is a tail call
- function foo(){
bar(); }// bar is not a tail call. The function returns undefined when no return is given
- const foo = () => bar(); // bar() is a tail call
- const foo = () => (poo(),bar()); // poo is not a tail call, bar is a tail call
- const foo = () => poo() && bar(); // poo is not a tail call, bar is a tail call
- const foo = () => bar() + 1; // bar is not a tail call as it requires context to return + 1
TCO is also known as PTC (Proper Tail Call) as it is referred to in the ES2015 specifications.