javascript - When caching vars, what is the best way to call it? -


if cache var:

var = $('#something'); 

i have seen being used later as:

$(something).doaction(); something.doaction(); 

is there difference in using either? have started using something.doaction() looks cleaner , easier read. i'd know if cause problems?

$(...) returns jquery object.

if put jquery object in variable, variable still hold jquery object in when check on later, else might put in variable.

no magical gremlins come , rid of jquery object behind back.
(unless accidentally put else in variable elsewhere)


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -