Refactoring and Pure functions - vijayetar/seattle-301d55 GitHub Wiki

Refactoring

Pure Function definition :

It returns the same result if given the same arguments
Pure functions benefits : The code’s definitely easier to test. Impure functions : have random number generator ; use external files ; or not always have values as parameters.

Immutability :

Unchanging over time or unable to be changed. When data is immutable, its state cannot change after it’s created. If you want to change an immutable object, you can’t. Instead, you create a new object with the new value.

pure functions + immutable data = referential transparency

Higher-order functions

When we talk about higher-order functions, we mean a function that either: takes one or more functions as arguments, or returns a function as its result


send information js = module.exports = Person


const Person = require('...filepath');