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
Post a Comment