JavaScript Arrays
Software Engineer intern @Azend Technologies | 3rd year)| Undergraduate at Faculty of Information Technology | BSc (Hons.) ITM | University of Moratuwa.
An array in JavaScript is a data structure that allows you to store multiple values in a single variable. You can create an array by using square brackets and separating the values with commas.
push(): adds an element to the end of an array
pop(): removes the last element from an array
shift(): removes the first element from an array
unshift(): adds an element to the beginning of an array
slice(): returns a new array with a specified subset of the original array
splice(): adds or removes elements from an array
concat(): combines two or more arrays into a new array
join(): converts an array to a string, with a specified separator
sort(): sorts the elements of an array in ascending or descending order
reverse(): reverses the order of the elements in an array
map(): creates a new array with the results of a specified function applied to each element of the original array
filter(): creates a new array with all elements that pass a specified test
reduce(): applies a specified function to each element of an array and reduces the array to a single value