Currently, calling this() returns an error as this is not declared. That means that this feature will not conflict with any JS use of this. This will allow to call itself in a function or an arrow function. Examples:
// Factorial Function:
function factorial(n) {
return (n == 0) ? 1 : (this(n-1) * n)
}
// Factorial Lambda:
n => (n == 0) ? 1 : (this(n-1) * n)
// Fibonacci Lambda:
n => (n < 2) ? 1 : (this(n-1) * this(n-2))
// Is number a prime? Lambda:
n => {
for (let i = 2; i < Math.sqrt(n); i++)
if (n%i == 0) return false
return true
}
// Quick for loop from zero to hundred:
((n) => {
if (n > 0) this(n-1)
// Run code here that should be repeated 101 times, with n = 0 .. 100
})(100)
The use of a quick way to call the function you're in allows for so many expressive ways to write problems. Hoping this to be reviewed!
