Skip to content

Instantly share code, notes, and snippets.

@warborn
Last active October 12, 2018 17:30
Show Gist options
  • Save warborn/87e9cab45f12aa93ac4430f555c009d9 to your computer and use it in GitHub Desktop.
Save warborn/87e9cab45f12aa93ac4430f555c009d9 to your computer and use it in GitHub Desktop.

Introduction to Functional Programming in JavaScript

  1. Benefits of Functional Programming
  2. Pure Functions & Side-Effects
  3. Point-Free style
  4. Function Composition

Benefits of functional programming

  • Useful patterns tested and proven along the years
  • "Code that you don't understand is code that you cannot trust"
  • Less to read
  • Improve the readability of the code

Pure Functions & Side-Effects

  • All functions are procedures but not all procedures are functions
  • Side-effects make a code a lot harder to read and to reason about
  • There is no useful program with no Side-effects
  • Avoid Side-effects wherever possible

Point-Free style

  • The map between the parameter and the argument
  • The intent of Point-Free style is that most of your code doesn't have points, there are points but we collect those points into well known, established, provable, verifiable utilities.

Function Composition

  • Make the steps of data transformation as obvious as possible
  • Partial application and Currying are different techniques to make a specialized version of a generalized function

Resources

FP course by Kyle Simpson

Functional-Light JavaScript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment