JavaScript Methods That Every Beginner and Pro Should Use

A collection of the most used JavaScript methods for writing clean and efficient code

Nabil Nalakath
Oct 29, 2019 · 4 min read
Image for post
Image for post
Photo by Tyler Franta on Unsplash

JavaScript is a language that needs no introduction. With 69% of the mighty developer population using it in their daily lives, it’s very easy to say it’s one of the most popular programming languages that exist out there. According to The State of Developer Ecosystem 2019 survey conducted by JetBrains, JavaScript and its frameworks top all the categories in the poll.

Although ES7 or ECMAScript 2016 syntax is already out, a majority of developers still use ES6 or ES5 while writing code. In this article, we are going to take a look at some of the most useful JS methods available as of the ES 2016 release.


Arrays are one of the most used data types in JS, and luckily we have a very good set of methods to make any array operation a walk in the park.

Finding if a particular value exists in a given array is one of the most basic operations we will have to perform on an array in almost every case. The find method is a very short and sleek method that does this for you in JS, avoiding the need to write loops on your own every time you want to find something.

This is very useful in conditional statements where want to proceed only if the value is present. Line 8 in the above code snippet statement will return true if 4 exists in the array, and false otherwise. Short and simple! And you can perform the same operation on an array of objects as well.

find() on an array of objects

It does what it says, gives you the index value if the value is present in the array and -1 if it’s not present.

Note:find and findIndex() methods will return the first element or its position that satisfies the given test function or expression.

It gives you a new array, with all the values from the given array that satisfy the given condition or test.

The same method works with an array of objects as well.

filter() on array of objects

The include method simply returns true or false after checking whether the given array contains the provided element or not.

The spread operator is a utility operator that be used for multiple purposes, like copying an array or concatenating two arrays.

spread operat


Now let’s take a look at some of the most commonly used methods on strings available on JS. One important thing to note here is that all these methods are case sensitive, so be cautious when you use them in such scenarios.

Yes, you guessed it right. It tells you if a given string starts with a particular substring.

Obviously there is an endsWith() as well. It returns true if a given string starts with a particular substring, and false otherwise.

includes() method quickly checks if the string includes a given substring and returns a corresponding boolean value.


“In JavaScript, objects are king. If you understand objects, you understand JavaScript “— W3Schools

Everything in JS can be considered as an object. But in this case, we will be talking about methods on objects as in common JSON object lit.

The Object.assign() method can be used to copy all enumerable own properties values to a target object from one or more source objects.


This method can also be used to clone an existing object into a new one.

If you’re dealing with nested objects, you should note that Object.assign() will only create a shallow copy, which will duplicate the top-level properties, but the nested object is shared between the original object and the copied object, i.e. a reference to the original object was copied.

One of the quickest ways to get around this shortcoming in JS is to stringify the JSON and parse it again before assigning it to the new object.

This gives us a copy of the original object with all the nested properties (except methods), and it creates this copy without reference to the original object. So any changes made to the new object will not be reflected in the original Object.

Note: Some of these methods may not work in legacy browsers like IE. Check browser compatibility and make sure you’re using transpilers or polyfills in your project if you need to support these browsers.

Advice for programmers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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