Tag Archives: javascript

JavaScript Inheritance Patterns

In this post, I am going to introduce to you 3 different ways of how you can implement inheritance in JavaScript. You will see inheritance implemented in languages such as Java by allowing a class to inherit state and behavior from a superclass, where each superclass can have many subclasses. This means that in Java an object is an instance of a class, which can inherit other classes. Now in JavaScript, being prototypal by nature, an object can inherit from an object. For the rest of this post, I will introduce the Pseudoclassical, Functional and Prototypal inheritance patterns in JavaScript.

JavaScript Inheritance Patterns

In this post, I am going to introduce to you 3 different ways of how you can implement inheritance in JavaScript. You will see inheritance implemented in languages such as Java by allowing a class to inherit state and behavior from a superclass, where each superclass can have many subclasses. This means that in Java an object is an instance of a class, which can inherit other classes. Now in JavaScript, being prototypal by nature, an object can inherit from an object. For the rest of this post, I will introduce the Pseudoclassical, Functional and Prototypal inheritance patterns in JavaScript.

Preserve `this` with recursive setImmediate()

In my node.js app, I need to use setImmediate() to recessively call a function and keep its context intact for next execution.

Consider following example:

var i=3;

function myFunc(){
    console.log(i, this);
    --i && setImmediate(arguments.callee);
}

myFunc();

Output:

3 // a regular `this` object
2 { _idleNext: null, _idlePrev: null, _onImmediate: [Function: myFunc] }
1 { _idleNext: null, _idlePrev: null, _onImmediate: [Function: myFunc] }

As you can see, after first execution this is overwritten. How should I work around this?

Preserve `this` with recursive setImmediate()

Salam (means Hello:))

In my node.js app, I need to use setImmediate() to recessively call a function and keep its context intact for next execution.

Consider following example:

var i=3;

function myFunc(){
    console.log(i, this);
    --i && setImmediate(arguments.callee);
}

myFunc();

Output:

3 // a regular `this` object
2 { _idleNext: null, _idlePrev: null, _onImmediate: [Function: myFunc] }
1 { _idleNext: null, _idlePrev: null, _onImmediate: [Function: myFunc] }

As you can see, after first execution this is overwritten. How should I work around this?

10 Tips to Make Your Node.js Web App Faster

Node.js is already blazing fast thanks to its event driven and asynchronous nature. But, in the modern web just being fast is not enough. If you are planning to develop your next web app using Node.js you must take every possible step to make sure your app is faster than usual. This article presents 10 tips that are known to speed up your Node based web app tremendously. So, let’s see each of them one by one.

10 Tips to Make Your Node.js Web App Faster

Node.js is already blazing fast thanks to its event driven and asynchronous nature. But, in the modern web just being fast is not enough. If you are planning to develop your next web app using Node.js you must take every possible step to make sure your app is faster than usual. This article presents 10 tips that are known to speed up your Node based web app tremendously. So, let’s see each of them one by one.

Node.js Production Practices – Developer Center – Joyent

As part of our stewardship of Node.js®, this resource is dedicated to sharing tools and techniques we use at Joyent to operate Node.js in production. From coding styles and design considerations through debugging large distributed systems, we intend to document our Node.js development and production practices.

Node.js Production Practices – Developer Center – Joyent

As part of our stewardship of Node.js®, this resource is dedicated to sharing tools and techniques we use at Joyent to operate Node.js in production. From coding styles and design considerations through debugging large distributed systems, we intend to document our Node.js development and production practices.

OOP In JavaScript: What You NEED to Know

In this article, we are concerned with only Inheritance and Encapsulation since only these two concepts apply to OOP in JavaScript, particularly because, in JavaScript, objects can encapsulate functionalities and inherit methods and properties from other objects. Accordingly, in the rest of the article, I discuss everything you need to know about using objects in JavaScript in an object oriented manner—with inheritance and encapsulation—to easily reuse code and abstract functionalities into specialized objects.

OOP In JavaScript: What You NEED to Know

In this article, we are concerned with only Inheritance and Encapsulation since only these two concepts apply to OOP in JavaScript, particularly because, in JavaScript, objects can encapsulate functionalities and inherit methods and properties from other objects. Accordingly, in the rest of the article, I discuss everything you need to know about using objects in JavaScript in an object oriented manner—with inheritance and encapsulation—to easily reuse code and abstract functionalities into specialized objects.

10 Node.js best practices you should follow – Innofied

Node.js is a platform built on Chrome’s JavaScript engine (i.e. v8 JavaScript Engine); it helps to develop fast, scalable network application. It is basically used in server side coding, handling AJAX requests, maintaining routes for different APIs and manipulating database. Node.js uses an event-driven, non blocking I/O model that makes it lightweight and efficient. Now without defining v8 the blog will remain incomplete. v8 is Google’s open source JavaScript engine which is written in C++. Best feature of v8 is: it can run independently, or can be embedded into any C++ application. Let’s come to the main topic; here are the Node.js best practices: