Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 2.25 KB

File metadata and controls

35 lines (31 loc) · 2.25 KB

FUNCTIONAL PROGRAMMING

Functional Programming Concepts

  1. What is functional programming?
  2. What is a pure function and how do we know if something is a pure function?
    • The function return values that are the same for identical arguments.
    • Impure function: eg a function that uses a global object in its calculations that is not passed in as a parameter of the function
    • The function does not cause any side-effects
  3. What are the benefits of a pure function?
    • testing code is easier
    • can do unit testing on pure functions in different contexts
  4. What is immutability?
    • inability to be changed
    • the function shouldnt alter the original value of the argument passed in.
    • eg: value + 2, if value is passed in as an argument and needs to be incremented
  5. What is Referential transparency?
    • a function that consistently returns the same result given the same input as arguments
    • requires a pure function and immutibility to be referentially transparent

Node JS Tutorial for Beginners #6 - Modules and require()

  1. What is a module?
    • a logical section of code that can be called on when it is needed to execute code
  2. What does the word ‘require’ do?
    • allows you to import/read JS modules that exist in separate files
    • it reads the file, executes the files contents, and then returns the exports object
  3. How do we bring another module into the file the we are working in?
    • with require('file path')
    • dont have to put .js on the end of the file
    • eg let functionName = require(filePath);
  4. What do we have to do to make a module available?
    • export the file to make it available to other files with the 'export' keyword to make it available for require/import
    • module.exports = <function you want to be available outside fof the module>