javascript-allonge icon indicating copy to clipboard operation
javascript-allonge copied to clipboard

named functions incorrect syntax?

Open raganwald opened this issue 10 years ago • 0 comments

in https://leanpub.com/javascript-allonge/read#leanpub-auto-limits

limits

Named function expressions have limits. Here’s one such limit: You can do simple recursion, but not mutual recursion. For example:

var even = function (num) even { return (num === 0) || odd( num - 1) };
var odd  = function (num) odd  { return (num  >  0) && even(num - 1) };

shouldn't those functions be

var even = function even (num) { return (num === 0) || odd( num - 1) };
var odd  = function odd (num) { return (num  >  0) && even(num - 1) };

raganwald avatar Oct 26 '13 17:10 raganwald