2

Can you explain to me what this JavaScript code means?

const TRUE = x => y => x;
const FALSE = x => y => y;
const IFELSE = p => a => b => p(a)(b);

console.log(IFELSE(TRUE)('1')('2'));  // The result is: 1
console.log(IFELSE(FALSE)('1')('2')); // The result is: 2
andy0570
  • 578
  • 5
  • 12
  • 2
    Lambda calculus. – user202729 Jan 31 '19 at 11:26
  • 1
    I don't think OP is asking about arrow functions in general but about the usage here (lambda functions, lambda calculus). I'd say this post is not a dupe. – eddiewould Jan 31 '19 at 11:29
  • I dont' think this is a duplicate, but this question doesn't have any value except for fun: anyone with enough knowledge of Javascript can figure out what it does, and nobody writes such code in practice. – user202729 Jan 31 '19 at 11:29
  • 1
    I dont think this is a dup? hes asking about currying – Joe Warner Jan 31 '19 at 11:31

0 Answers0