Saturday, 15 June 2013

use of "that" keyword in javascript -



use of "that" keyword in javascript -

this question has reply here:

what 'var = this;' mean in javascript? 6 answers

i have few javascript has used keyword "that" extensively. see lot of posts talking javascript keyword "this".

i wanted understand meaning of key word in javascript context , it's visibility/scope.

something

that.somefunctionaname(someparameter)

what mean?

i understand keyword "this" points owner of current object.

that not keyword in javascript. suspect code have using in class define instance of itself. example:

function myclass() { var = this; }

by doing this, can ensure you're referencing object, , not element. example, consider next sample:

function myclass() { var = this; $('.myele').click(function() { // 'this' refers element clicked. // 'that' still refers myclass() object. }); }

javascript

No comments:

Post a Comment