arrow

Arrow Functions

Traditionally, functions are defined in JavaScript by using the “function” keyword. In ES2015, arrow functions were introduced. For C# folks, this will look similar to lambdas. Let’s first look at a traditional function syntax…

function getName(){
    return ‘Bongo’;
}
console.log(getName()); 

The output would be “Bongo”. Let’s change the syntax to using arrow function syntax…

let getName = () => {
     return ‘Bongo’;
}
console.log(getName()); 

This would also output “Bongo” to the console. Basically, arrow functions made the syntax for writing functions cleaner and smaller.

Happy Coding!

Clay Hess

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email
Skip to content