Simple way to convert NodeList into Array in javascript

So what is going on with the above statement? Here’s what’s going on:

  1. getElementsByTagName does not return Array object. Instead it returns NodeList (You can easily test it out on the developer tools. i.e. document.getElementsByTagName(‘li’).constructor)
  2. NodeList does not have array methods. Prototype type chain is not connecting to array prototype at all. (NodeList.prototype.__proto__.constructor == Object)
  3. slice returns a new array object so using slice against NodeList converts NodeList into Array

quick note on “use strict”

I just want to make a quick note on “use strict” in javascript.


  1. won’t allow to create a global variables
  2. Illegal assignment throws an exception
  3. attempt to delete undeletable properties throws an exception
  4. all named properties must be unique
  5. function parameter names must be unique
  6. octal syntax is not permitted

Late inheritance with __proto__ in javascript

In JavaScript there are so many different ways to inherit a super class. For example, Object.create, jQuery.extend, Child.prototype = new Parent(), and so on.

However, it’s not common to use __proto__ to create inheritance chain in javascript. Let me get to it right now.

So that does not look quite impressive. One cool thing about __proto__ is that any instance gets it when created. In javascript pretty much anything can be overwritten, which means after you create a regular object you can still make the instance inherit from a particular Class. Here’s a good example of late inheritance.

It sorta worked, but how about parent Class’ constructor execution? Unfortunately you will have to run one line of code as a late inheritance penalty.

That was a technique used by many old actionscript developers back in the days to create inheritance chain… We were cautious about its usage since it was undocumented feature and it could have been changed without telling anyone. I’m not sure if all browsers support that syntax, but that’s something good to know and understand how javascript works in my opinion anyways.

News Ticker (HTML5 : canvas)

I used to make news ticker in flash very long time ago. Today I wanted to make a very simple javascript news ticker using canvas. It took about 15 mins for me to make this basic structure. If I want to make it dynamic like loading external rss-feed or something like that it can be done too, but for now I’m too lazy to add them… maybe later…

source code