code-301-reading-notes

View project on GitHub

Concepts of Functional Programming in Javascript

  • Functional programming is a programming paradigm
  • It is a style of building the structure and elements of computer programs
  • Functional programming is pure functions
  • We can say that a function is pure if:
    • It returns the same result if given the same arguments
    • It does not cause any observable side effects
  • We can say that a function is impure if it uses a global object that was not passed as a parameter to the function.
  • Pure functions are stable, consistent, and predictable.
  • Given the same parameters, pure functions will always return the same result.
  • When data is immutable, its state cannot change after it’s created.
  • pure functions + immutable data = referential transparency
  • The idea of functions as first-class entities is that functions are also treated as values and used as data.
  • 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

Refactoring JavaScript for Performance and Readability

  • Refactoring Your Code means that you have to edit your code in easier way to get the same result, so it will be more readable.
  • A hash function is used to map a given key to a location in the hash table.