Message from JavaScript discussions
April 2018
— Uhmmm
#ask is there any different between use
$(selector)
and difine the selector inside object somethin like
modal: $(selector)
— Rather than repeatly typing
$(selector)
— #solved
— If you mean store the selector in a variable (or in a object property) vs repeatedly typing the selector, the only difference would be time of execution. The later would kind of ensure the element selected exists, the stored one may have an old reference.
— Well, neither would ensure existence
— Simply put: They do different things
— Can you explain why it's different and what make it different ? . I read jquery documentation that selector can be define as variable. simply put
$
at beginning of variable its self. example:
$variable
— The difference is in the time they run
— Aa ic
— #ASK is there any method if forEach done then do something. something like ajax there is a method call success
— $var = '.selector', $($var) - function call that returns wrapper