DEV Community

acode123
acode123

Posted on

Top 3 JavaScript tips I wish someone had told me

Hello World!

After my dev.to tip post got popular, I thought you guys might also enjoy some of my best JavaScript tips. I promise these tips are unique(and not copied from Wikipedia). ๐Ÿ˜‚

Please comment below if you got some tips for me! Learning with you here! ๐Ÿ‘ Okay, let's get to the juicy bit. Because I don't want to waist your time, I won't get too detailed, but each tip would get it's unique post in the future!

Tip 1 (OOP- Object Oriented Programming)

This is a tip for people planning to have any kind of graphics on their website/application. If you don't fit into that description, consider skipping to the next tip.

Okay, now that 75% of you left this paragraph, let's talk about objects! Basically, to get started, let's make a class.

class reallyadvancedthing{
   constructor(x, y){

   }
   draw(){

   }
}
Enter fullscreen mode Exit fullscreen mode

Good, now you know some stuff you might not understand. I promise I'll try my best to write a post about JavaScript objects tomorrow. But for today, just stay tuned!

Tip number 2(Comments)

I know, you've probably seen this tip somewhere else, but I am going to get more detailed! ๐Ÿ˜„ Comments help you organise your code, not just for you, but for your fellow developers looking at your code.

You must realise that your code is made to serve the community you're in. You need to help others understand your code's purpose. As Albert Camus once said:

A man without ethics is a wild beast loosed upon this world.

Now let's talk about you. You probably already forgot 90% of what your code does after a few days, and that's not something you want. You don't want to waist those countless hours you spent, at least, add a few basic comments so you know how to use your product!

Tip number 3(Functions)

What's the use of repeating yourself over and over again when you can just use a JavaScript function? JavaScript functions speed up your code and development process.

Trust me, one function can save you an hour, twenty four can save you a whole day of coding, give it a shot!

Conclusion

Hope you enjoy it, as usual, I promise I'll reply to all your questions in the comment section! It'll make my day if you gave this post a like?

Top comments (0)