Hacker News new | comments | show | ask | jobs | submit login

A small nit:

Specifically the sayName function was created in the global scope, so when it came across the statement this.name it looks in the global scope for the value of name.

It doesn't matter where a function is created, but it matters how it's called. A pretty simple example is that typing sayHello() by itself desugars to sayHello.call(window);, where window is the global scope[1]. JavaScript function invocation is fairly confusing until you learn the rules.

I also really liked Yehuda's JS prototypes article[2]. It really helped me understand them.

[1]: Except in JS strict mode apparently? I don't know too much about that. See http://yehudakatz.com/2011/08/11/understanding-javascript-fu...

[2]: http://yehudakatz.com/2011/08/12/understanding-prototypes-in...

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact