Arrow functions, also called “fat arrows” were introduced with ES6 as a new syntax for writing Javascript functions.
By utilising a token (=>) that looks like a fat arrow, they are a more concise and elegant way of writing function expressions.
Basic Syntax
//ES5 Way
function myFunc() {
//statements here ...
}
//ES6 Way
myFunc = () => {
//statements here ...
}
Parentheses in ES6 functions are optional when only one parameter is passed.
myFunc = val => {
return val += 1;
}
alert(myFunc(2)); //3
But if no parameters are passed to the function, then parentheses are required.
Isomorphic Labs, a drug discovery start-up launched four years ago and owned by Google’s parent…
Regardless of whether TikTok faces a U.S. ban, Instagram is wasting no time positioning itself…
Amazon Web Services (AWS) continues to enhance its customer experience by offering more flexible payment…
JavaScript, often hailed as the "language of the web," continues to dominate the programming landscape…
Amazon is accelerating efforts to reinvent Alexa as a generative AI-powered “agent” capable of performing…
SpaceX's satellite-based Starlink, which is currently unlicensed for use in India, is reportedly being utilized…