Sunday, June 4, 2017

NodeJS Practical Usage 1

Install NodeJS command prompt
Type node -> JS engine -> EG: 1+1 -> yields 2
ctrl c twice to exit

Editors
Visual studio code - good debugger -> step over, step into
Atom

MODULES
Reusable block of code does not impact other code

First class functions -> Use like variables -> functions are objects

//function statement
function calculate(){
  var a=1;
  var b=2;
  var c=a+b;
  console.log(c);
}

calculate();

//functions are first class
function logCalc(calculate){
  calculate();
}

logCalc(calculate);

Expression -> Block of code that results in a value

//function expression and its first class
var calcAll = function() {
  console.log('Hi expression');
}

calcAll();

Function on the fly


No comments:

Post a Comment