JavaScript React Basics (retired) Stateful Components Updating State

SH Ding
SH Ding
3,125 Points

At 6:30 in this video, what is the difference between calling decrementScore and decrementScore().

What is the difference between each of the two and what it does? When would you choose one over the other?

1 Answer

Steven Parker
Steven Parker
203,994 Points

When you use just the name of a method as an argument, you are passing a reference to the function itself. This is often referred to as a "callback". The function is not called by making this reference.

When you put parentheses after a method name, with or without arguments inside, you are calling the function, and what you pass as the argument is whatever the function returns when it finishes running.

Which one of these you would use is determined by the argument requirements of the function you are passing it to, and possibly also by what the function returns.