Introduction to NodeJs

Defination of NodeJS(V8/Chakra)

Javascript on your backend servers.. A wrapper arround v8 with build in moduled providing rich features through easy to use asynchronous APIS

Why Node?

Pros

Wrapper around V8(execute JavaScript) Built in Moudles (fs, http, crypto, zip..) Asynchronous APIs (No threads) parallel programming without using threads c++ addons Debugger and other utilities NPM Module dependency managers(CommonJs Modules and EcmaScript Modules) Full Stack one language anywhere

Cons

Different way of thinking Picking good options small packages

smaller code is why node is named as node

we build simple small single process building blocks node that are organized using good networking protocols. scalling node is not after thought, its built right into it.

Callback

A fancy term for function. “A function that Node will “call back” at later point in the time of program.”

// this is callback function that accepts data as an argument
function cb(data) {
  // do something with data
}
/*we pass callback function reference here to some asychmethod, this asycnch method will get the callback invoked when data is ready.*/
someAsyncMethod(cb);

Promises

its like asking chicken for chick, and chicken gave us egg, this egg could turn into chick or it could be a bad egg.

samer.dev/code-analogies samer.dev/callbacks

Previous
Next