Which Array methods I’m using in my daily coding as a senior developer. part 1.

The array is one of the most useful concepts in programming with a lot of native methods which most of the time remembering is very hard even for experienced developers. that's why I decided to write this post and explain and introduce the methods I am using in my daily coding life as a developer.

First of all, what is Array?

An array is a single variable that is used to store different elements.

How should I know a variable is an array?

it’s simple Let's take a look at the below image.

First 4 lines we define 4 types of variables (array, object, string, null).

  1. The array has a Bracket around elements like the first line
  2. In lines 6 to 8, I use the helper or utility function to see if my variables are array or not. Array.isArray(value) utility function returns true if value is an array.
  3. line 10 to 12 are clear enough so let's move on to the next topic

Maybe you ask yourself what can I do with an array.

let me explain I store my data inside of an array and it helps to access those data and loop through them and do any operation I like.

I have to tell you Array has many helper functions like join, map, every, find, filter, and …

let me share some most useful of them which I use every day at my work.

.map()

This helper will create a new array and will call a provided function and run it for each element of the array.

Ok you want to see it in a real-life example ok doki you can find it below how I use it in my react project

.filter()

This helper will create a new array and with all elements that pass the test function provided to the filter method.

real-life example:

.sort()

This helper will sort your array without creating a new array and it will modify your original array.

.join()

This helper will join all elements of an array into a string. this function will accept one parameter to joins every element with that. and the result will be a string.

Hey, don't worry I have some easy methods for you guys too.

.push(), .shift(), .pop(), unshift()

these methods will help you to add and remove an element to the end and beginning of a list.

There is a lot more. I will cover them in my next article.

Opinion

you don't need to know every single syntax or method of any language you are working with, but you need to know them such thing exists so when the time comes you know how to search and find about it there is a lot of good articles and resources on the internet befriend with different platform and keep them open and read them in your daily basis.

Summary:

We learn some of the most useful methods I and most of the developers are using in their daily life. not sure about others but it's a very rare situation I need to write an algorithm or very very complicated logic and to be a senior developer doesn't mean you have to know all syntaxes and solve all logic in a minute.

about me

My name is Ali and I'm a full-stack web developer at BuildDirect and co-organizer at a meetup group called React-dojo.

if you like the article please don't forget to clap it means a lot to me

also don't forget to follow me on Instagram with hashtag #reactdojo.

Resources

Share

--

--

--

If you want to know more about me follow me on instagram and Linkedin and shoot me a DM

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Getting Started your application using Nuxt Vuejs with Typescript

Understanding JavaScript Runtime!

How to copy Objects in JavaScript?

Functions in Swift

Scim-patch, a library to patch SCIM resources.

Callback Functions in JavaScript

Difference Between find() and filter() in JavaScript

Understand Routing in Vue.js With Examples

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
React Dojo

React Dojo

If you want to know more about me follow me on instagram and Linkedin and shoot me a DM

More from Medium

Implement 5 Sorting Algorithms using JavaScript.

Top 10 React Interview Questions — 2021

oop in javascript! part1: prototype

Day6 - #100DaysOfCode - Finish React, Start Redux