why does const current = setInterval(() => setSeconds(seconds => seconds + 1), 1000) work but not const current = setInterval(() => setSeconds(seconds + 1), 1000) ? what is the difference between those two?
const current = setInterval(() => setSeconds(seconds => seconds + 1), 1000)
const current = setInterval(() => setSeconds(seconds + 1), 1000)
Hi Siyu! Thanks for the question. An arrow function makes an implicit return :) so we can see the incrementing of time visually on the browser page.
What do you mean exactly by "An arrow function makes an implicit return"?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
why does
const current = setInterval(() => setSeconds(seconds => seconds + 1), 1000)
work but not
const current = setInterval(() => setSeconds(seconds + 1), 1000)
?what is the difference between those two?
Hi Siyu! Thanks for the question. An arrow function makes an implicit return :) so we can see the incrementing of time visually on the browser page.
What do you mean exactly by "An arrow function makes an implicit return"?