Modules
  • Modules are reusable blocks of code.
  • NodeJS introduced CommonJS Modules. CommonJS is just a set of standards. A CommonJS module.
  • It's the way NodeJS basically set out conventions on how you should build your module.
  • Modules are protected. Code we write inside doesn't affect other areas of our codebase.
  • Modules are IIFE

First class functions

Functions are first class. We can pass them around like variables; Like we discussed Functions are variables. You can pass a function to a function.

function greet() {
  console.log('Hi');
}
 
function logGreeting(fn) {
  fn();
} 
 
logGreeting(greet);

Function Expression

var functionExpression = function() {
  // i am a function expression
}
 
var functionExpression = function foo() {
  // i am a function expression
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License