Quiz
- I'm still a bit confused about why we can't pass f() directly as an argument. Is it because we don’t want to call the function immediately, but rather invoke it only when the user clicks on something?
Exactly right! Contrast these two:
Clearly, the first invokes f and only gives the return value (which might not exist) to the
click
method.We (usually) want the second.
- I want to talk more about method chaining.
Sure. We'll see some examples throughout the course. Basically, anytime you want to do:
You can instead do:
$("some selector").meth1().meth2();