Function and Variable Hoisting

It is quite straightforward to look at the JavaScript code snippet bellow and conclude it will output in to the console the result of 2. But for those coming from a C background, it may come as a surprise that Forward Declaration of the avg function is not required. console.…

The Good Parts

On the right you have a controversial and strict idea of "how to use the language properly" from an inspirational and influential member of the community and on the left you have a "deep dive into the language". To make it interesting, Crorckford (The Good Parts) actually referred to Flanagan…

borrow a method with call()

Sometimes we want to use an object's method on a different object. Such a thing is possible in Javascript through the usage of the call() method. Let's take the Array.prototype.slice method as an example, which returns a new array object from a portion of an existing one. This…

Navigation Timing

The W3C Navigation Timing specification defines an interface for web applications to access the complete timing information for navigation of a document. What this basically means, is that you can programmatically get an understanding of how much time the browser has spent on the different tasks required to load a…

new operator

At some point in time, when trying to mimic classical inheritance in JavaScript and the call to super(), I did doing something stupid like this: function Animal(name, age) { this.name = name; this.age = age; } function Dog(name, age, color) { this.color = color; Dog.prototype = new Animal(name, age); } var…