Arrays In Javascript
- Introduction to Array
- Creating an Array in Javascript
- Creating an Array with only Zeros/Only One
- Adding Elements in the Array
- Adding Elements to the start of the Array
- Adding elements to the end of the Array
- Removing Elements From the Array
- Removing Elements from the start
- Removing Elements from the rear
- Accessing the Elements in the Array
- Positive and Negative Indexing
- Using Indexof to find the index of the element
- Finding the length of the Array
- Iterating through elements of the Array
- Checking the type of Array
- Slicing And Splicing the Array
- Sorting an Array
- Checking if the Array Contains A particular value
Introduction to Array: An array is a collection of data which may or may not be of the same data type
Creating an Array in Javascript There are two ways in which we can create arrays in JavaScript. The most easy and mostly used way of creating a JavaScript array is
- Creating an Array with only Zeros / Ones
4.Adding Elements in an Array Elements can be added in two ways one at the start and second at the end of the Array
- Adding elements at the start of the array
2.Adding Elements at the end of the Array
- Removing Elements from the Array
Elements in array can be removed from the start or from the rear
- Removing elements from the Start
start index is included and end index is excluded
- Removing from the rear
- Accessing Elements using Index: JavaScript Arrays are 0-based indexes.This implies the starting index is 0 They only support positive indexing.
If we try to use negative indexing to access the elements then we will get the output as undefined
Using indexof to find the index of the first occurrence of the element in the array
- Finding the length of the Array
- Iterating through all the elements of the Array
- Checking the type of Array
Arrays in JavaScript are treated like Objects
Slicing and Splicing an array
1.slicing
2.Splicing
- Sorting an Array By default sorting order is increasing
12.Checking if the value Is present or not If the value is present then it will return true else will return false