Node.js – Step-by-Step Guide For Getting Started


Node.js Step by step tutorial – The goal of this article is to get you started with developing applications with Node.js following the technology’s best practices, teaching you everything you need to know about this relatively young technology all the way from basics to the “advanced” level along the way.  

To test code:

Quick Links for Javascript Developers

The following are some of the important guide references for better development and javascript / node.js coding structure.

Node.js is JavaScript on the server, how cool is that?

We cannot speak about Node.js without mentioning Javascript. In fact Node.js is Server-side JavaScript. All the web developers must have been in touch with JavaScript some, that because JavaScript live in browsers during a long time. The language itself was purely frontend focused and we had to use it with some backend languages such as PHP or .Net to archive meaningful functionalities. But this is just the context. Today and with node.js, JavaScript became a “complete” language you can use it in many contexts and achieve everything with it you can achieve with any other “complete” language. In fact you can now use the same language in both the front end and server side of the projects, it allows you to run JavaScript code in the backend, outside a browser.

In order to execute the JavaScript you intend to run in the backend, it needs to be interpreted and, well, executed. This is what Node.js does, by making use of Google’s V8 VM, the same runtime environment for JavaScript that Google Chrome uses.

Javascript Tutorial – Closures

Outside Scopes and contexts closures are one of the most vital features in JavaScript language. Knowing how to implement closure is crucial to a successful and well written JavaScript code. On this chapter I will guide you on how to easy understand the concept of closures and how to implement it in the wright way.

What is a closure in JavaScript?

Wikipedia: In computer science, a closure is a first-class function with free variables that are bound in the lexical environment. Such a function is said to be “closed over” its free variables. A closure is defined within the scope of its free variables, and the extent of those variables is at least as long as the lifetime of the closure itself.

Basically a closure is explained very simply by Tim Caswell as a function within another scope that has access to all the variables within the outer scope.

How to use Closures

The following examples shows how we call the function that generate another function or group of functions but hides all the stare in private variables within the closure. The function message is included in the Person function.

Note: According to the rules of closures all the child scopes have access to the parent scope or variables within a function. Basically this means that the parent variable

function Person(name, age) {
 var person = 'name: ' + name + ' Age: ' + age;
return function message() {
// Generate the closure
var PersonName = Person('Lea', 27);
//Use the closure
OUTPUT: Bob, who is 47 years old, says hi! 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.