开发者

ext js this argument

I开发者_开发问答n ext-js, what is the difference between doing:

this.combo= new Combo(....)

and

var combo = new Combo().

Also...is there a debugger, System.out.print kind of functionality in ext js whereby I can see what is the object contained in 'this' at any moment?


Console.log() in chrome developer's tool or firefox's firebug its equivalent to System.out.print

If you're in a function then "var" will create a local variable, else its on the global scope. As far as this it works abit different in javascript than in java. In JavaScript this always refers to the “owner” of the function we're executing, or rather, to the object that a function is a method of. Here is a run through of using this in javascript:

The this keyword in javascript


Just wanted to add to the above answer that, it gets trickier when it comes to events as to what this refers. By default, this refers to the object that fired the event. Meaning that say if you have an AJAX request in an object o using Ajax.request ({...}), this in the success event handler by default refers to the Ajax request object not object o. But, you can always pass a scope parameter while registering your handler function to guarantee what this refers in the handler function. Thank you!


For the first question:- this.combo is the current object which fired the event and the var combo is just initialization of a combo box which can be used in the doc. Also, there should be consideration which scope you want while using this.

For the second question:- we can use the debugging options and then the break points to go through what this contains. If you have not put any break point, it by default contains the window object.

ext js this argument

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜