gil00pita
6/11/2016 - 10:31 PM

Lambdas or Arrow function expressions

Lambdas or Arrow function expressions

//Optional and default parameters

//Before
var executeStandingOrder  
    = function (amount: number = 100, description?: string) {
        var message = 'Standing order amount = $' + amount;
        console.log(message);
    }

//After
var executeStandingOrder2  
     = (amount: number = 100, description?: string) => {
        var message = 'Standing order amount = $' + amount;
        console.log(message);
    }
//Before
var calculateInterest = function (amount, interestRate, duration) {  
    return amount * interestRate * duration / 12;
}

//After
var calculateInterest2 = (amount, interestRat, duration) => {  
    return amount * interestRate * duration / 12;
}

//Further
var calculateInterest3 = (amount, interestRate, duration) => amount * interestRate * duration / 12;