Skip to the content.

Code 301 Class 08 Reading Notes

Consepts of Functional Programming in Javascript

  1. What is functional programming? Functional programming is a pragramming paraadigm - a style of building the structure and elemnts of computer programs - that treatscomputation as the evaluation of mathematical functions and avoids changing-state and mutable data - Wikipedia ~ Reference
  2. What is a pure function and how do we know if something is a pure function?
  3. What are the benefits of 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
  4. What is immutability Unchanging over time or unable to be changed.
  5. What is Referentiality transparency If a function consistently yields the same result for the same input.

pure functions + immutable data = referential transparency

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

  1. What is a module? A module is another JavaScript File.
  2. What does the word ‘require’ do? It passes a function from one module to another.
  3. How do we bring another module into the file that we are working in?
    1. Write out require(''), and withing the paranthesis and string is going to be a path to the module that we require in the file we are working in.
    2. Then, write in the the file that we want to bring in with a dot and foward slash. require('./count.js')
  4. What do we have to do to make a module available?
    1. Write module.exports = which sets whatever we want to be made available outside of this module.
    2. Write the function counter we would like to be available outside of this module module.exports = counter;
    3. In thefile we want to pass to, create a variable to the require we are passing through let counter = require('./count');
    4. Type in node app in your terminal, and thats how we create a module and how we require a module in another JavaScript file.

Things I want to know more about

<—BACK