Functional Programming
Functional Programming Concepts
- What is 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 — Wikipedia - Medium.com
- What is a pure function and how do we know if something is a pure function?
- It returns the same result if given the same arguments (it is also referred as deterministic)
- It does not cause any observable side effects
- What are the benefits of a pure function?
- Pure functions are stable, consistent, and predictable. Given the same parameters, pure functions will always return the same result
- The code’s easier to test
- What is immutability?
- When data is immutable, its state cannot change after it’s created
- What is Referential transparency?
- if a function consistently yields the same result for the same input, it is referentially transparent.
pure functions + immutable data = referential transparency
Node.js
- What is a module?
- What does the word ‘require’ do?
- returns the exported from whatever is passed to the require func
- How do we bring another module into the file the we are working in?
let someVariable = require('./pathToTheThingINeed')
- What do we have to do to make a module available?
module.exports = theThingsToExportFromThisFile;
Things I Wish I Knew More About
References