First, a sample use case:

    var myArray = ['one', 'two', 'three'];

    Array.prototype.a = function() {
      console.log(this);
    }

    Array.prototype.b = {};
    Array.prototype.b.c = function() {
      console.log(this);
    }

> myArray.a()
>> ["one", "two", "three"]
> myArray.b.c()
>> "Object"

>From the code above you can notice that:
- when "this" keyword is used inside Array.prototype.a() function then
it refers to Array.prototype object
- when "this" keyword is used inside Array.prototype.b.c() function
then it refers to Array.prototype.b object

How can I access Array.prototype inside Array.prototype.b.c() function?

When building constructor functions I could easily work around
limitated scope of "this" keyword by assigning "var self = this" at
the beginning of the constructor. Is there a simillar trick that would
allow me to alter the scope of "this" in prototypes?

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to