DEV Community

Discussion on: 10 Awesome JavaScript Shorthands

Collapse
 
crimsonmed profile image
Médéric Burlet

I think this shorthand:

let fruits = ['🍉', '🍊', '🍇', '🍎'];

// Using forEach method
fruits.forEach(function(fruit){
  console.log( fruit );
});

//=> 🍉
//=> 🍊
//=> 🍇
//=> 🍎
Enter fullscreen mode Exit fullscreen mode

If you are logging it can be simplified like this:

let fruits = ['🍉', '🍊', '🍇', '🍎'];

// Using forEach method
fruits.map(fruit => console.log(fruit))

//=> 🍉
//=> 🍊
//=> 🍇
//=> 🍎
Enter fullscreen mode Exit fullscreen mode
Collapse
 
palashmon profile image
Palash Mondal

Thanks for your feedback. ❤️

I have already mentioned that shorthand in the "7. Arrow Functions" section. I hope that is fine.

Happy Coding!