Shalvin Interests

Saturday, October 27, 2018

Node JS

Node is a JavaScript based Web Framework. Node's Non-blocking architecture makes it a very popular framework. V8 is the Virtual Machine of Node.


Node REPL
Once Node is installed, Node REPL can be invoked by typing node in the command prompt.



Typing tab tab in the prompt  displays  all Global command.

If you type a module name followed by tab tab it will display all the options pertaining to it.





Creating Http Server


const http = require('http');

const server = http.createServer((req, res) => {
  res.end('Hello World\n');
});

server.listen(4242, () => {
  console.log('Server is running...');
});


setTimeOut

setTimeout(
  () => {
    console.log('Hello after 4 seconds');
  },
  4 * 1000
);

Functions and Arguments
const consulting = who => {
  console.log(who + ' consulting');
};

setTimeout(consulting, 2 * 1000, 'Shalvin');

No comments:

Post a Comment