Mujeeb Ahmed Profile picture
Mar 9 25 tweets 9 min read
JavaScript Arrays🤩, Mega thread🚀.
All of the content includes examples so that any aspiring Web developer can quickly grasp the concepts. Image
1. What is a JavaScript Arrays.
An array in JavaScript is a variable that can hold several values.
Example: Image
2. What's the Point of Using an Array?
If you have a list of items (say, a list of car names), storing the cars in single variables might look like this:
Example: Image
But what if you want to go through the cards one by one and find a specific one? What if you had 500 cars instead of three?
An array is a solution!
An array can store many values under a single name, and the values can be accessed by referring to an index number.
3. Making an Array.
The simplest way to create a JavaScript Array is to use an array literal. ImageImage
4. How to Recognize an Array.
A common question is: How do I know if a variable is an array?

The problem is that the JavaScript operator typeof returns "object":

Solutions: Image
5. Accessing Array Elements.
The index number is used to access an array element:

Note: Array indexes start with 0.
[0] is the first element. [1] is the second element.[2] is the third element. Image
6. Changing an Array Element.
we can change the value of the elements in an array.
Example: Image
7. Accessing the Full Array.
The full array can be accessed in JavaScript by referring to the array name:

Example: Image
8. Arrays are Objects.
Arrays are a portion of objects. In JavaScript, the type of operator returns "object" for arrays.

JavaScript arrays, on the other hand, are best described as arrays. Image
9. Array Elements Can Be Objects.
Variables in JavaScript can be objects. Arrays are a subset of objects.

As a result, you can have variables of various types in the same Array.

An Array can contain objects. An array can contain functions. An array can contain arrays: Image
10. Array Properties and Methods.
The real strength of JavaScript arrays are the built-in array properties and methods: Image
11. The length Property:-
The length property of an array returns the length of an array (the number of array elements).
Example: Image
12. Accessing the First Array Element
=>Returns the first element of an array
Example: Image
13. Accessing the Last Array Element

=>Returns the last element of an array

Example: Image
14. Updating the Array:
1. push():
Adds one or more elements to the end of an array, and returns the new length of the array. Image
2. pop():
Removes the last element from an array and returns that element. Image
3. shift():
Removes the first element from an array and returns that element. Image
4.unshift():
Adds one or more elements to the front of an array, and returns the new length of the array. Image
15. Filtering/Finding Elements in array methods:

1. at():
The at() method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array. Image
2.indexof():
The indexOf() method returns the first index (position) of a specified value.
The indexOf() method returns -1 if the value is not found.

3. find():
The find() method returns the first element in the provided array that satisfies the provided testing function. ImageImage
4. findindex():
The findIndex() method returns the index of the first element in the array that satisfies the provided testing function, else it will return -1

5. filter():
The filter() method creates a new array with array elements that pass a test. ImageImage
6. includes():
The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.

7. every(): The every() method check if all array values pass a test. ImageImage
8. some():
The some() method tests whether at least one element in the array passes the test implemented by the provided function. It returns true if, in the array, it finds an element for which the provided function returns true; otherwise it returns false. Image
9. reverse()
Reverses the order of the elements of an array in place. (First becomes the last, last becomes first.

10. concat()
Returns a new array that is the calling array joined with another array or value. ImageImage

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Mujeeb Ahmed

Mujeeb Ahmed Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @mujeeb0147

Mar 7
JavaScript Objects 🔥🔥(Thread).
1. What is an Object in JavaScript?

The Object class represents one of JavaScript's data types. It's used to store keyed collections as well as more complex entities
2. How can you Create a JavaScript Object?

With JavaScript, you can define and create your objects.

There are different ways to create new objects:

1. Create a single object, using an object literal.

2. Create a single object, with the keyword new.
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(