Technology

Node.js: Unit Testing with Jasmine framework

Jasmine is a framework which is used for testing node.js code or javascript code. Installation To install the latest official version, use NPM: [js]npm install jasmine-node -g[/js] Write the specifications for your code in *.js and *.coffee files in the spec/ directory Execution After installing the npm package, you can...

by Sahil Chitkara
Tag: node.js
14-May-2013

Technology

Create Basic HTTP Server with Node.js

Like other languages(Java, php), we do not need to set up any Apache HTTP server. With Node, things are a bit different, with Node.js, we not only implement our application, we also implement the whole HTTP server. In fact, our web application and its web server are basically the same. Lets create a basic Node HTTP server. First let's...

by Amit Kumar
Tag: node.js
10-May-2013

Technology

Clustering in Node.js

Node.js is single threaded so it runs one process on a single CPU, as the power of Node.js is its performance and speed it doesn't seem good to use only one CPU in a multi-core system. For utilizing all the CPUs, Node.js allows us to create a network of processes that all shares the same port. Create a file named clusterExample.js ...

by Shreyance Jain
Tag: node.js
25-Feb-2013

Technology

How to implement Inheritance in js2

We are assuming that you have installed js2 in your system, in case if you have not installed js2, first install js2. First of all create a InheritanceTest.js2 file in scr directory with the content given below: [js] class Person { // Parent class var firstName; var lastName; function initialize(firstName, lastName)...

by Amit Kumar
Tag: node.js
18-Feb-2013

Technology

Getting started with js2

We are assuming that you have installed node.js in your system, in case if you have not installed node.js, first install node.js. To install js2 run the command given below: [bash] npm install js2 [/bash] Let’s create a simple Hello World project, but first let’s create a project directory structure: [bash] mkdir...

by Amit Kumar
Tag: node.js
16-Feb-2013

Technology

Node.js: Getting started with Express.js and MongoDB

In my previous post, I explained how to get started with node.js and executing your first script with node. Now in this tutorial, we will go a step ahead and learn using Expressjs and MongoDB. For people who are new, Express is a web application framework for node which provides a set of features that can be used to build single-page as...

by Suroor Wijdan
Tag: node.js
08-Feb-2013

Technology

Getting started with node.js on Linux

In this tutorial i will walk you through the installation of node.js on your Linux system and executing your first script with node. To get started goto the official node.js website and download the Linux Binaries file (as shown in the screenshot below) according the bit version of your system. Save the downloaded file in a specific...

by Suroor Wijdan
Tag: node.js
01-Feb-2013

Node.js

How to Remove Duplicate Elements from Array in JavaScript

Arrays in JavaScript are daunting and particularly difficult in nature. The fundamental reason for making this statement is that JavaScript does not provide as many functions/methods for array operations as several other languages do. As a result, an array operation as simple as removing duplicate elements from an array may also be...

by Sakshi Tyagi
Tag: node.js
01-Feb-2013

Technology

Difference between call() and apply() method of JavaScript

Many people get confused with these two functions in JavaScript, most of the time people think that we can pass an object in apply() and access it with this which is not possible with the call() method. But that is not the case, let's see an example which will make it more clear. Using call() method: [js] (function sum(a,b,c) { ...

by Suroor Wijdan
Tag: node.js
30-Jan-2013