JavaScript JavaScript and the DOM Traversing the DOM Getting the First and Last Child

Heather Gray
Heather Gray
6,224 Points

Old JavaScript functions?

Why in this lesson are we not using arrow functions or other ES6 functions? I get confused because we were taught these cool new ES6 features in the previous module but they're not used.

2 Answers

Matthew Leroe
Matthew Leroe
10,115 Points

E6 adds 'syntactic sugar' with arrow functions, but doesn't require that you use them. Maybe in some cases it's more readable to do a function declaration or expression. That's my guess. I'm curious as to what someone more experienced might say.

Brendan Whiting
MOD
Brendan Whiting
Front End Web Development Treehouse Moderator 82,989 Points

There are some differences between ES6 arrow functions and regular functions that are more than just syntactic sugar. I pretty much default to using arrow functions all the time now though.