You can't do it in the descriptive/declarative way in JS, but you can listen to the value of the parameter and react accordingly:
var Function1 = (n) => {
if (n === 0) return 1;
if (n === 1) return 1;
return Function1(n-1)*n;
}
document.write(Function1(3),"<br/>"); // 6
Another way would be to return a curried function:
var Function1 = (n) => {
if (n === 0) return () => 1;
if (n === 1) return () => 1;
return () => Function1(n-1)()*n;
}
document.write(Function1(3)(),"<br/>"); // 6
Mind the second function call here Function1(3)()
.
Your example could be shortened a bit with a ternary operator, but it works against maintainability and readability:
var Function1 = (n) => [0, 1].includes(n) ? 1 : Function1(n-1)*n;
document.write(Function1(3),"<br/>"); // 6