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 trialMark Plattner
2,082 PointsWhat's the story with () => ?
What is going on here with ",() => {}"
myButton.addEventListener('click', () => { myHeading.style.color = myTextInput.value; })
This wasn't covered in Intro to JS and I know => is not an operator? So the whole syntax is confusing to me. Can you please explain it?
4 Answers
Unsubscribed User
15,508 PointsYeah, Michael Caveney hit the nail on the head! :) It's the ES6 way of writing function() {...}
. There's a few other benefits we're getting from writing function expressions as arrow functions, which that introduction to arrow function syntax course covers. :D
Mark Plattner
2,082 PointsCool! Thanks
Omar Hamza
Courses Plus Student 1,985 PointsThank you for the answer Steve :)
Mohammed Zeeshan
Courses Plus Student 3,302 PointsThis gave me crystal clear explanation [https://teamtreehouse.com/library/anonymous-functions-2]
Michael Caveney
50,144 PointsMichael Caveney
50,144 PointsIt's an Arrow function, part of ES6 JS, those are talked about in the ES6 course, and there's a workshop on them here: https://teamtreehouse.com/library/introducing-arrow-function-syntax