I have a javascript function that has a number of methods and variables and returns an object literal, which I use somewhat as a class, i.e.
var myObject = function {
var somevars;
var someMethod = function(someInput) { };
return {
methodA:function(inputs) {
},
methodB:function(inputs) {
}
};
}
In javascript, a variable is usually created called "this" or "I", or such a thing that stores the value of "this" at creation time, so that in future calls you can use it to point to your own objects because "this" may indicate something other. This is useful if, for example, methodA is used as a click handler.
How can I create the variable "this" in the returned object?
"" - , ?
, , , -.
, A methodB . "this".
"". X. X.methodA , . jquery, mouseup dom X.methodA. $( "# domElementId" ). Mousemove (X.methodA) mousemove, "this", A, X, . , . , A, , B, , this.methodB "this" .