JavaScript jQuery Basics Introducing jQuery jQuery vs. JavaScript

Is using an arrow function okay?


like this?

2 Answers

Balazs Pukli
Balazs Pukli
46,065 Points

Yes. If it works, then it's OK. And it should work.

Code snippet from OP looks like it's missing a couple curly braces, but you can absolutely use an arrow function. Here's the same example from the video using arrow function syntax:

$('.box').click(() => {
  alert('You clicked me using an arrow function!');