reading-notes


Project maintained by will-ing Hosted on GitHub Pages — Theme by mattgraham

Refactoring

functional programming

Functional programming is a programming paradigm — a style of building the structure and elements of computer programs — that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data

Pure functions - It returns the same result if given the same arguments

Properties -

// global object that was not passed as a parameter to the function.
let PI = 3.14;

const calculateArea = (radius) => radius * radius * PI;

calculateArea(10); // returns 314.0


// This is a the pure function example
let PI = 3.14;

const calculateArea = (radius, pi) => radius * radius * pi;

calculateArea(10, PI); // returns 314.0

Immutability - Unchanging over time or unable to be changed.

strategies for easier code

Main Page