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

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

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