How to Create a Constructor in JavaScript

Constructors in JavaScripts! Sounds odd. Right? But yes Constructors in JavaScripts are widely used by developers now days. And you too should consider it, as it may help you make your code neat. Enough Gyan! Lets code: function Programmer(id,name) { = id; = name; this.describe = function( ... Read more »

Comparison Dilemma in JavaScript

In real life, you may not encounter such situation however, this article will give you insights on how type conversion and comparisons happen in javascript. Let’s start with code var a = -1; if(a) console.log("Anything but JS"); else console.log("Even assembly will do!"); Output Anything but ... Read more »

Initializing Empty Arrays in JavaScript

Two ways of defining empty arrays with number of elements specified var arr1 = new Array(3); var arr2 = [,,]; But new keyword for array definition is never recommended. Now Suppose I have 3 text fields ,whose data I want to store in an array. var arr = [,,]; for(var i=0; i& ... Read more »

A boolean false can be true in JavaScript

JavaScript has bad reputation for its sloppiness,anything can happen in javascript. Lets see such an example. What is boolean ? Boolean() is a constructor function in javascript which can be used to make a boolean data type variable. It can be used either for making boolean data type variable or ... Read more »