Top 10 things a JavaScript Developers should learn at the beginning

As you have already ended up here so I believe you are familiar with JavaScript which is a widely used language. Just a fact check that initially it was decided to name LiveScript but to use the popularity of Sun Microsystem’s Java language, as a market strategy, it named JavaScript.

As it’s worldwide popular, it has a vast library which helps you to do anything and any way you want. Let’s talk about some of the essential features of it.


  1. The Problem with Integer/Number

JavaScript is a bit tricky when it comes to numbers. It has two built in number systems, Number and BigInt. Number type is actually double-precision 64-bit binary format IEEE 754 value where it is not strictly an integer rather a float type. So see the example where it gets tricky -

So in case you want only the integer part (and not the part after decimal point), you can use Math.floor() function. An example -

However, to use various functions for mathematical operation, you should give a look to the Math library of JavaScript.

2. Converting a String to an Integer

This is something very interesting and also essential. There can be a lot of times when you might have got a number from an object or an input field and it’s in a string format, what would you do then? To solve such a problem, parseInt() is a very essential function.

The interesting part is, while parsing the string, if you get a non-decimal number, you can easily convert it to decimal as well.

Here ‘base’ is an argument where you can declare which number system that number is based on. Let’s say you got a number 177 which octal and you want to convert it in decimal format.

But another similar function parseFloat() always get the base 10, not anything else so be careful with that.


3. How long is the Word/Sentence/Paragraph/Essay?

We often need to try loop on a string property and for that we need to know how long it can be. So here is a solution for you, stringName.length. You can try it on any string even if it’s a huge essay and it will say how many characters are there. But one thing you need to remember that spaces, white spaces and punctuation marks are also considered as characters.

4. What if you don’t want the whole string but a part of it?

Let’s say you have a string which is pretty big and you just need a portion from there, how can we cut it to the part you desired? Well, as I stated earlier, JavaScript has a vast library so that you can do anything in any way you want. So, let’s say you have a string which is “It’s been a pretty big blog already, I think I have just written half of it.” Now you need only the part before the comma. To get the desired result, there is a function called slice(). It needs two parameters, the first one will be the starting index and the second one will be the ending index and as we know the starting is counted from 0. So our code will look like this -

5. You want to split things from a specific position?

“I am very tired and hungry” — Let’s say from here, you want every word individually without the space. Using slice will be tiresome work. So you can split() the sentence whenever there will be a space. And our code will be -

As we can see, the result will be an array of subarrays of words. Cool huh?

6. Adding two Strings

Let’s say you have two strings and you want to add them. As an example, “This is an example” and “of adding two strings”. If you use ‘+’ operator like algebraic function, they will be added. The code will look like -

That little empty string is for adding a space in output. Try removing, you might understand!

The Others!

7. Truth or False!

This is actually a boolean expression. Let’s say you want to check if a number is greater than 7 or not and if it is greater, you want to print “big number”.

The output is desired because here the statement is True.

But the fun fact is, Truth or False doesn’t stop here rather their capability is much vast. Such as any empty string, NaN (Not a Number), Null and Undefined values are false. And expectedly the opposites are True.


Array is a special type of object and very much used. There are numerous methods for array. We will discuss a few here.

8. Removing from Start or End

Let’s say you want to remove an item from an array and it’s either the first element or the last. To Remove from the first position, you should use the shift() method and to remove from the very last position, you should use the pop() method. Example -

9. What about modifying an array from a specific position?

splice() is a very flexible and useful method when it comes to modifying an array. You can delete items from a specific position to a specific number of elements and you can add some new items as well!

The syntax looks like this — arrayName.splice(starting_index, how_many_items_to_be_deleted, newItem1, newItem2,….newItemN)

And if you don’t want to add any item rather just delete then syntax would be like this — arrayName.splice(starting_index, how_many_items_to_be_deleted)

Let’s see and example -

10. Trying to reverse everything?

reverse() method is very handy in certain times. Usually it needs a few lines of code to perform the action but this little method can save you from that trouble. Example

That’s all for today. Hope to see you soon in another blog!

MERN Stack Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store