Arrow function in Lightning Web Component (LWC)

Arrow functions are compact alternatives to regular JavaScript functions. The advantage of arrow functions is that it does not bind its own this.


Let's understand with an example.


this is regular function expressions ->

import { LightningElement, track, api } from 'lwc';
export default class App extends LightningElement {

// Event will be fired on button click
handleClick(event) {
 let myName = new this.Employee('Saurabh'); 
 myName.info();  
}

Employee = function(__name) { 
 this.my_name = __name; 
 this.info = function() { 
         console.