JavaScript Arrow Function


function sum(a, b) {

  return a + b;

}



let sumArrow = (a, b) => {

  return a + b;

}



let sumArrowShort = (a, b) => a + b;





function isPositive(n) {

  return n > 0;

}



let isPositiveArrow = (n) => {

  return n > 0;

}



let isPositiveArrowShort = (n) => n > 0;





function randomNumber() {

  return math.random;

}



let randomNumberArrow = () => {

  return math.random;

}



let randomNumberArrowShort = () => math.random;





document.addEventListener('click', function() {

  console.log('Clicked.');

});



document.addEventListener('click', () => {

  console.log('Clicked.');

});



document.addEventListener('click', () => console.log('Clicked.') );

Leave a Comment