Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Basics (2018) Understanding State Handling Events

Why no function keyword to define function?

Aren't functions usually defined using function?

function incrementScore() {
   console.log('Plus one point!');
}

With that being said, the code only works without the use of function keyword and not as shown above, but why?

1 Answer

Emmanuel C
Emmanuel C
10,636 Points

It's because youre creating it inside a class, then it no longer becomes a function, its now a method. The only difference between a function and a method is that a method is attached to a class. But they both act basically the same.

Routine Poutine
Routine Poutine
26,050 Points

Wow, I totally missed this logic. Thanks!