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
What is a pure function and how do we know if something is a pure function? A pure function:
-
Returns the same result if given the same arguments (it is also referred as deterministic)
-
Does not cause any observable side effects
What are the benefits of a pure function? A pure function’s values cannot be changed over time, so it will always work. Ensuring that a function is pure is a way to future-proof the fdunction because it has no dependencies and the values that it draws from will not change.
Pure functions are easier to test
What is immutability? Unchanging over time or unable to be changed.
What is Referential transparency? pure functions + immutable data = referential transparency
Node JS Tutorial for Beginners #6 - Modules and require()
What is a module? Consider modules to be the same as JavaScript libraries. A set of functions you want to include in your application.
What does the word ‘require’ do? The basic functionality of require is that it reads a JavaScript file, executes the file, and then proceeds to return the exports object.
How do we bring another module into the file the we are working in? To include functions defined in another file in Node. js, we need to import the module. we will use the require keyword at the top of the file. The result of require is then stored in a variable which is used to invoke the functions using the dot notation.