12
Jan

JavaScript rule number one

Forget everything you know about OOP.

var mammal = {getName:function(){console.log("I am a mammal")}};

var Cat = function() {this.getName = function() {console.log("I am a cat")}};
Cat.prototype = mammal;

var Man = function() {this.getName = function() {console.log("I am a man")}}
Man.prototype = mammal;

luke = new Man();
luke.getName();

>>> I am a man

luke instanceof Cat
>>> true

If you are thinking “WTF???” you are wrong. JavaScript objects are decoupled from constructors and instanceof is just a unlucky naming to say something as simple as:

luke.__proto__ == Cat.prototype;

23
Jul

English?

For a little bit of time this blog will be not anymore in an almost correct Italian but in a seriously broken English.
Yes, it’s time to give me a try about English blogging.

I’ve decided also to use a new theme for this blog. I really like the old one, but it’s not the best one to show “lines of codes” and nerd stuff… and in the next future I’d like to talk a lot about web code, and forget for a time “the Universe and Everything”.

Please, say me good luck.

18
Feb

my last Labor http://github.co…

my last Labor http://github.com/agiardina/Fango

10
Feb

bellissimo :) http://www.ilpen…

bellissimo :) http://www.ilpenemidailpane.it/

4
Feb

medioevo informatico, ovvero c…

medioevo informatico, ovvero come ti tutelo gli interessi del berlusca http://tinyurl.com/yenwvem

31
Jan

clean the house or don't clean…

clean the house or don’t clean the house, that’s the problem!

7
Jan

neve e armageddon a dublino so…

neve e armageddon a dublino sono sinonimi

28
Dec

rispolvera la digital ixus

rispolvera la digital ixus

27
Dec

e gli errori necessari

e gli errori necessari

27
Dec

che c'e' di meglio di un trasl…

che c’e’ di meglio di un trasloco a Natale?

Next Page »