Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to write an arrow function in javascript?

function double(x) { return x * 2; } // Traditional way
console.log(double(2)) // 4


const double = x => x * 2; // Same function written as an arrow function with implicit return
console.log(double(2)) // 4
Source by mbeaudru.github.io #
 
PREVIOUS NEXT
Tagged: #write #arrow #function
ADD COMMENT
Topic
Name
6+7 =