DEV Community

Discussion on: Six (Dirty) Ways to shorten your Javascript

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️
arr.forEach(console.log);
Enter fullscreen mode Exit fullscreen mode

If you really want to golf your code, you could also replace forEach with map, since this will have the same effect except creating a new array that never gets used:

arr.map(console.log);
Enter fullscreen mode Exit fullscreen mode
  • Misleading
  • Poor performance
  • Saves 4 letters

Worth 👍