5 Javascript Tips – Part 1

Side Hustle Freelancer

5 Javascript Tips – Part 1

If you’re always looking to improve your skills on Web development, or you’re a new developer and you want to learn something useful, well know that I’m about to offer you 10 tips that have been useful and that I have to know today, to develop in a creative and functional way!

It’s not the only thing I will do! I will publish tips, Q & A or tutorials / courses on Web development from day to day.

I’m doing this because writing code is my passion as well as my work, and after years of searching on Google or Git. where other people were helping me, now I want to be the one to spread that knowledge I’ve learned.
So I ask only one thing before starting, follow me on Social (IG: @adeveloperday, Twitter) and subscribe to this blog! I assure you that I will not create spam.

As you know, JavaScript is the world’s number one programming language for the web. Think about Netflix, thanks to JS and Node JS, it can be what it is today.
Its use varies from simple scripts embedded in millions of HTML pages, to more complex structures that are part of Server-side logics (es NodeJS).

The difficulty of this language is not high in itself, but it can become according to the needs of the product to be realized, here are 5 tips and best practices that I adopt during my life as a developer

1. Debug, Debug and Debug

Oh yes .. If you are a developer you’ll know for sure, but as a first advice I have to tell you to use the various debugging tools at your disposal.

To debug client logics (Javascript) we must exploit the console made available by our browser (accessible with inspect element or F12), and, in my opinion, the Chrome console is one of the best, simple and functional.

At this point you need to learn how to use the console and know 3 key points for debugging:

  • console.log();
  • debugger;
  • break point

The first one will show us, on the console, the value of variable (or function …)  that we want to use, the remaining two will allow us to follow the progress of the code step by step, for a discussion on this issue I refer you to the appropriate article.

2. Use === instead of ==

The == (or! =) operator is used for a comparison, the problem is that JavaScript automatically converts the values ​​of the variables if necessary, while the operator === (or! ===) compares the actual value of two 2
variables , for example:

'' == false // is true, but 'stringa' == true is false
'' === false // is false

[9] === 9 // is false
[9] == 9 // is true

[] == 0 // is true
[] === 0 // is false

'10' == 10 // is true
'10' === 10 // is false

3. Use the semicolon

Usually, in JS, the semicolon would not be necessary to use a semicolon, but I recommend using it, as a best practice even just for the code’s maintainability.


I found myself many times having to pass data to servers, but they gave problems on the types of objects that are transferred. The JSON format has saved me on many occasions.

In JS there are 2 ways to serialize and deserialize an object as a string: JSON.stringify, JSON.parse

5. Keep attention to the for…in

As the last piece of advice for this article, let’s talk about for (var k in m).

This particular type of iteration is not strictly equal to a classic forEach that is used on other languages ​​(C # or Apex), but its adapt to the type of data passed as a parameter to iterate.
For example, by passing an Object, k will take the values ​​of the properties and passing an Array, k will assume the index value.

These are the first 5 tips and best practices I wanted to share with you, let me know in the comments what you think, and follow me on my social channels so you can talk to me. 🙂


Nessun commento

Aggiungi il tuo commento