
Arrow Functinos in JavaScript
Arrow functinos are a new syntax for functions in JavaScript. Here are a few examples:
let f = (a, b) => {
let c = 4;
return a + b - c;
};
let g = x => x * x;
Due to their brevity, arrow functions make writing functions easier and more readable. However, it sould be noted that arrow functions are not just a syntactical sugar, they have important differences with norrmal functions. The most important difference is that they don't have a this binding separate from the outer scope. This makes them very useful, for example, for using with array functions, such as forEach, etc. Also, they don't have an arguments binding. To remedy this, you can use the rest parameter syntax (...rest).
Leave Arrow Functinos in JavaScript to:
Read more #technology posts
Best Posts From ghasemkiani
We have not curated any of ghasemkiani's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From ghasemkiani
- Merging PDF Files with Java
- Happy Iranian New Year
- Stephen Hawking, one of the greatest physicists of our time, dies at 76
- Using Scoped NPM Packages
- Optimistic Typing in Nashorn
- JavaScript Basics: Reflect.apply
- JavaScript Basics: Reflect.construct
- JavaScript Basics: Reflect
- New Horizons Broke the Record of the “Pale Blue Dot” Picture
- JavaScript Basics: Object.freeze and Object.isFrozen