Created
August 30, 2020 16:49
-
-
Save rahulmalhotra/cdf53541bbebcefa2d9b44609abb83c6 to your computer and use it in GitHub Desktop.
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
// * Fat Arrow Functions in JavaScript | |
// * Method 1 | |
function perimeterOfACircle1(radius) { | |
const PI = 3.14; | |
return 2 * PI * radius; | |
} | |
console.log(perimeterOfACircle1(10)); | |
// * Method 2 | |
let perimeterOfACircle2 = function(radius) { | |
const PI = 3.14; | |
return 2 * PI * radius; | |
} | |
console.log(perimeterOfACircle2(10)); | |
// * Method 3 | |
let perimeterOfACircle3 = (radius) => { | |
const PI = 3.14; | |
return 2 * PI * radius; | |
} | |
console.log(perimeterOfACircle3(10)); | |
// * Method 4 | |
let perimeterOfACircle4 = radius => 2 * 3.14 * radius; | |
console.log(perimeterOfACircle4(10)); | |
// * Method 5 | |
let perimeterOfARectangle = (length, breadth) => 2 * (length + breadth); | |
console.log(perimeterOfARectangle(10, 20)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment