Skip to main content

Lambdas

Lambdas

  • simple expression: (x, y) ⇒ x+y

  • block statements:

  • the parament support object/array destructuring: (obj) ⇒ obj.field1 + obj.field2 OR ({field1, field2})

(x, y) => {
let a = x + 1
return a + y
} // explicit return is required
  • the lambda parameter support object/array destructuring:
  // obj is a map/object type variable
(obj) => obj.field1 + obj.field2
// OR
({field1, field2}) => field1 + field2