Does look need to return a function? I think what you are trying to do is this:
Objecte.prototype.look=function(){
alert(this.name);
}
However, this in this context will be resolved when the function is executed and could be bound to another object. I think it is clearer in any case to use the closure declaration of objects instead of using the prototype. You could declare your object this way:
function Objecte(name) {
var that = this;
this.name = name;
this.look = function() {
alert(that.name);
}
}
The disadvantage is that every object of the type Objecte will have its own copy of the function look, but when was the last time you ran out of memory?
Another disadvantage is that you can't inherit from another object, rewrite a method and later call the original method from this object, as it will be lost. However disadvantageous that is..
.call(this,event)on it, resulting inthisreferencing the clicked element and not yourthis.Objecthas meaning in JavaScript!