Friday 1 July 2016

javascript - What are the this() pointing to in this function is it pointing to the Array?

I'm a little confused about the function below, specifically the use of this(). I want to know to what this() refers to.



Array.prototype.Swap = function (x,y) {  
var b = this[x];

this[x] = this[y];
this[y] = b;
return this; // return the current array instance.
}


Is it pointing to the function itself, or to x or y?
I checked the other topics that talked about this() and i see that I talks about empty function and it’s not illustrates the prototype on it

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...