WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Adding functions with object prototyping, Micha Schopman, September 29, 2003
     Re:Adding functions with object prototyping, Wellington, September 29, 2003
         Re:Adding functions with object prototyping, Micha Schopman, September 29, 2003
         Re:Adding functions with object prototyping, Micha Schopman, September 29, 2003
             Re:Adding functions with object prototyping, Erik Arvidsson, September 30, 2003
             Re:Adding functions with object prototyping, Wellington, September 29, 2003

Subject: Re:Adding functions with object prototyping From: Erik Arvidsson Date: September 30, 2003
Just like Wellington posted. 'this' is bound to the closest object. This can be understood if one understands how methods works in JS. Methods are properties that have the type Function. When these are called using the object.method notation this is the same as calling the function, method, with object bound to this.

function f(n){}
obj.meth = f
// obj.meth = obj["meth"]
// obj.meth(n) = f.call(obj, n)
obj1.obj2.meth = f;
// obj1.obj2.meth = (obj1.obj2).meth = obj3.meth
// (obj1.obj2).meth(n) = f.call(obj1.obj2, n) = f.call(obj3, n)

I hope that made things clearer... If not I'll have to try to explain it in some other way because I believe it is important to understand this.

erik



Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX