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 trialjlampstack
23,932 PointsWhy 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
10,636 PointsIt'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
26,050 PointsRoutine Poutine
26,050 PointsWow, I totally missed this logic. Thanks!