{"id":8909,"date":"2019-01-27T09:30:05","date_gmt":"2019-01-27T14:30:05","guid":{"rendered":"https:\/\/www.carnaghan.com\/?p=8909"},"modified":"2021-03-25T20:56:51","modified_gmt":"2021-03-26T00:56:51","slug":"javascript-arrays-properties-and-methods","status":"publish","type":"post","link":"https:\/\/www.carnaghan.com\/javascript-arrays-properties-and-methods\/","title":{"rendered":"JavaScript Arrays – Properties and Methods"},"content":{"rendered":"
We are going to cover some of the most commonly used properties and methods in JavaScript, for working with arrays. There are a lot of other methods which are not covered here, including newer ES6 methods. The goal here is to get you started working with arrays and gaining an understanding of the fundamental ways we can access and manipulate data. The table below summarizes the various methods we will cover in this lesson:<\/p>\n
length property<\/td>\n | Sets or returns the number of elements in an array<\/td>\n<\/tr>\n |
find methods<\/td>\n | Returns the value (find) or index (findIndex, indexOf) of the first element in an array<\/td>\n<\/tr>\n |
sort, reverse, and compare<\/td>\n | Sorts, reverses, and compares the elements of an array<\/td>\n<\/tr>\n |
push and pop<\/td>\n | Adds (push) or removes (pop) new elements to the end of an array, and returns the new length<\/td>\n<\/tr>\n |
unshift and shift<\/td>\n | Adds (unshift) or removes (shift) new elements to the beginning of an array, and returns the new length<\/td>\n<\/tr>\n |
splice and slice<\/td>\n | Adds\/Removes elements from an array (splice) or selects a part of an array, and returns the new array (slice)<\/td>\n<\/tr>\n |
concat<\/td>\n | Joins two or more arrays, and returns a copy of the joined arrays<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n |