DEV Community

Discussion on: 9 years on, I still google "javascript for loop"

Collapse
 
jenbutondevto profile image
Jen

It depends on which editor you're using. for webstorm (IntelliJ), by default can type

  • fori: for (let i = 0; i < ; i++) { }
  • forin: for (const item in arr)
  • and forof: for (const item of array) { }

typing "for" for brings up this tooltip, I can select with arrows and press tab for it to autocomplete. if you remember which template you want, you can just type eg "fori" + tab without waiting for the tooltip to show up.
auto complete

It's also similar in vscode. iirc, typing for will give you a bunch of options for the different iterators.

Thread Thread
 
paugramming profile image
Pau Riosa

nice thanks man! awesome

Thread Thread
 
jenbutondevto profile image
Jen

your IDE will have a bunch of different ones. worth having a look wherever they're located in for other useful ones :)