what is an array ?
Array data structure is widely used in all programming languages that support it.but in this article we'll be looking at how to use it in JavaScript.
In programming, an array is a collection of elements or items. Arrays store data as elements and retrieve them back when you need them.
In this article and the next one, I'll teach you all about arrays in JavaScript. You'll learn about complex data handling, destructuring, the most commonly used array methods, and more.
Why this article on Array?
You'll agree with me that there are many great articles on JavaScript arrays already available around the internet. so why did I waste my time writing this One?
Well , for some time now I realize that most beginners need a tutorial that covers arrays thoroughly from beginning to end with visual examples.
So that was what encouraged me to write this article , if you're just getting started with JavaScript, I hope this will be helpful to you.
Also as an experience developer, I hope this will come handy to you . As I'm writing this article I'm also learning.so let's get right on it.
What is Array in JavaScript ?
When you go to your search engine (eg.google),you type Array and you click on the search icon, you'll find that there are a lot of definition on arrays. But I'll give a simple meaning.
In JavaScript, array is a single variable that is used to store different elements. It is often used when we want to store a list of elements and access them by a single variable.
Creating an array.
You can create array using an array literal,this is the easiest way to create a JavaScript Array. check the example below:
Why Use Arrays?
Let's say you have a list of names of cars , like the one in the image below,and you want to loop through the cars and find a specific one? you can use array . What If you have 300 and not 3? You can use array.
Conclusion.
Thanks for reading this introductory article on Array in JavaScript,I hope you found it helpful. In my next article I'll be explaining How to Get Elements from an Array in JS,How to Add Elements to an Array in JS and more.. so tune in,and till next time take care 😘.
Top comments (0)