DEV Community

Cover image for 9 years on, I still google "javascript for loop"

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

Nočnica Mellifera on March 19, 2021

cover image by Libertinus Yomango also despite writing Markdown every day for the last three years, I messed up the link above in v1 of this artic...
Collapse
 
jenbutondevto profile image
Jen

I usually let my IDE do that for me nowadays. typing "for" brings up an autofill for all the different ways to type a for loop, it saves a trip to my browser and back. No guarantees if I could type it from memory..!

Collapse
 
paugramming profile image
Pau Riosa

how do you that hehehe

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 :)

Collapse
 
cklek profile image
Conrad Klek

I would always delete robots.txt from whatever web boilerplate I was using. I didn’t know what it did and thought it was creepy

Collapse
 
nocnica profile image
Nočnica Mellifera
Collapse
 
rinsama77 profile image
imrinzzzz

I don't know if this is very relevant to the post, but I feel ashamed that I don't fit in with the stereotypical programmer geek. I'm one of the few women in my class who chose to pursue programming as a job after graduate. Most girls feel like they don't fit in, feel inferior, and chose to do other related work (e.g. product owner).

It wasn't really about gender, but it does play a role. What's most shameful is the fact that I'm not devoting all my time coding. I have other hobbies unrelated to programming (and photography, idk why but my "geek" friends tend to do these 2 things).

Most of the time I feel like I don't master this language/framework/tools enough to creatively and efficiently use it. That I'm not writing the most efficient code. I have this friend who likes to complain how people codes are bad (which I learnt from him a lot), and that put my confidence down lower than ever..

I'm trying to work on that, but it's exhausting sometimes not having people similar to you in the field or as a representative.

Collapse
 
nocnica profile image
Nočnica Mellifera

Coding has never been my hobby, and I've been super successful just by doing it at work. Those people who are looking at code 12 hours a day will, in all likelyhood, be burnt out in 5 years.

And keep in mind anyone questioning a new coder for their commitment is, i guarantee, insecure! Experienced devs confident in their skills don't question others.

Collapse
 
rinsama77 profile image
imrinzzzz

I see. Thank you so much! Also, seeing how you are confident to be yourself in this field has given me so much inspiration too!

Collapse
 
devdufutur profile image
Rudy Nappée • Edited

So don't use explicit loops 😅

new Array(10).fill(0)
  .map((elt, idx) => idx)
  .reduce((acc, elt) => acc + elt, "")
Enter fullscreen mode Exit fullscreen mode
Collapse
 
eljayadobe profile image
Eljay-Adobe

The best part of using this instead of a for loop: you'll never remember what you're supposed to search for on Google, so you'll be forced to memorize the pattern!

Collapse
 
devdufutur profile image
Rudy Nappée

Maybe this way of doing could seem a little overkill but has advantages :

  • No mutation
  • Each step in the pipeline of transformation is visible instantly
Thread Thread
 
eljayadobe profile image
Eljay-Adobe

Not overkill in my book. I'm a fan of Elm and F# and Haskell. I think this kind of FP approach will supplant OO in time.

Collapse
 
kodekrash profile image
James Linden

I think everyone does this. My kryptonite is 'this' in javascript. Sometimes, I go for weeks writing PHP only in (pick a) framework, and if I switch to 'vanilla' PHP, I have to google the simple things.

Collapse
 
aarone4 profile image
Aaron Reese

I write SQL, VBA, js, python and c#. Remembering the syntax difference is not worth the mental overhead when the internet will give you a copy paste answer in 30 seconds. What does wind me up though is the lack of wildcard consistency in the Microsoft stack.

  • In Access % in SQL ~ in Excel

Anyone got any other wildcards?

Collapse
 
otumianempire profile image
Michael Otu

I keep learning and relearning javascript over and over and over. I remember one time, it was a simple integration of a theme we bought for our dashboard. I was assigned the task of modifying one css class and ... it became the next three days css-ing. Respect to frontend developers.

Collapse
 
lorenzoblog profile image
Lorenzo

Hey, where is the content?

Collapse
 
nocnica profile image
Nočnica Mellifera

This is a discussion post! I'm asking you and other readers to comment back :)

Collapse
 
lorenzoblog profile image
Lorenzo

Ok, sorry for the comments. I was hoping for an article about this, I would be interesting!

Collapse
 
rahoulb profile image
Rahoul Baruah

It’s not shameful.

15 years writing Ruby code almost every day yet I still Google the Ruby CSV class at least once a week. It’s not even a complex class!

Collapse
 
jennapederson profile image
Jenna Pederson

SAME. I have to google it for JS and Ruby because there are different forms and they are similar, but just different enough that I get them all mixed up between the two languages. 🤦‍♀️

Collapse
 
nocnica profile image
Nočnica Mellifera

yeah I think this is what gets me: I write a little bit of Ruby, Python, and JS. It's that language confusion that gets me. When I write C# for games I'm much more confident since the syntax is so different!

Collapse
 
e99h2121 profile image
YAMADA Nobuko

Same. When I write new class in my work, I try to find good template of my teammate.

Collapse
 
egilhuber profile image
erica (she/her)

I keep the syntax for C# and VB for each loops on a post-it on my monitor!

Collapse
 
systemx profile image
Mohammed Fellak

Proud of you lol