Arrow operator to create function - Javascript Function

Javascript examples for Function:Arrow Function

Description

Arrow operator to create function

Demo Code

//Vanilla JS//from  w ww . j a v a2  s . c  o m
function squareVanilla(x) {
    return x * x;
}

let squareES6 = x => x * x;

// 6.
let squareAnonymous = function (x) {
    return x * x;
}

console.log(`Using Vanilla JS: ${squareVanilla(5)}`);
console.log(`Using ES6: ${squareES6(5)}`);
console.log(`Using Anonymous: ${squareAnonymous(5)}`);

Related Tutorials