Quick Reference
This is a quick reference list of JavaScript array methods and properties with examples of how they are used.
- JavaScript – Array concat() MethodThe Array concat() method joins two or more arrays, returning a new array containing the joined arrays, without changing the existing arrays.
- JavaScript – Array constructor PropertyThe Array constructor property returns the function that created the Array prototype.
- JavaScript – Array copyWithin() MethodThe Array copyWithin() method copies array elements to another position in an array, overwriting the existing values.
- JavaScript – Array entries() MethodThe Array entries() method returns an array iterator object that shows the key and value pairs currently existing within the array.
- JavaScript – Array every() MethodThe Array every() method executes a function for each array element, returning true if the function returns true or false.
- JavaScript – Array fill() MethodThe Array fill() method fills specified elements in an array with a value, overwriting the original array.
- JavaScript – Array filter() MethodThe filter() method creates a new array filled with elements that pass a test provided by a function, leaving the existing array unchanged.
- JavaScript – Array find() MethodThe Array find() method executes a function for each array element and returns the value of the first element that passes a test.
- JavaScript – Array findIndex() MethodThe Array findIndex() method executes a function for each array element, and returns the index (position) of the first element that passes a test.
- JavaScript – Array forEach() MethodThe Array forEach() method calls a function, running it for each item in an array.
- JavaScript – Array.from() MethodThe Array.from() method returns an array from any object with a length property.
- JavaScript – Array includes() MethodThe Array includes() method returns true if an array contains a specified value, and returns false if the value is not found.
- JavaScript – Array indexOf() MethodThe Array indexOf() method returns the first index position of a specified value, and returns -1 if the value is not found in the array.
- JavaScript – Array.isArray() MethodThe Array.isArray() method tests an object to determine if it’s an array. It returns true if an object is an array and false if the object is not.
- JavaScript – Array length PropertyThe Array length property sets or returns the number of elements in an array.
- JavaScript – Array join() MethodThe Array join() method returns an array as a string leaving the original array unchanged.
- JavaScript – Array map() MethodThe Array map() method creates a new array by calling a function for every array item.
- JavaScript – Array keys() MethodThe Array keys() method returns an array iterator object containing the keys of a specified array.
- JavaScript – Array pop() MethodThe Array pop() method removes and returns the last element of an array, changing the original array.
- JavaScript – Array lastIndexOf() MethodThe lastIndexOf() method returns the last position of a specified value, searching from right to left, returning -1 if the value is not found.
- JavaScript – Array.prototype PropertyThe Array.prototype property allows new properties and methods to be added to existing arrays.
- JavaScript – Array push() MethodThe Array push() method adds new items to the end of an array, changing the length of the array.
- JavaScript – Array reduce() MethodThe reduce() method executes a reducer function for every array item, returning a single value representing the function’s accumulated result.
- JavaScript – Array reduceRight() MethodThe Array reduceRight() method executes a reducer function for every array item, working from right to left, returning a single value.
- JavaScript – Array reverse() MethodThe Array reverse() method reverses the order of the items in an array, overwriting the original array.
- JavaScript – Array shift() MethodThe Array shift() method removes and returns the first element of an array, changing the original array.
- JavaScript – Array slice() MethodThe Array slice() method returns selected elements in an array as a new array, without changing the original array.
- JavaScript – Array some() MethodThe Array some() method checks if any array elements pass a test by executing a callback function for each array element.
- JavaScript – Array sort() MethodThe Array sort() method sorts the elements of an array as strings in alphabetical and ascending order, overwriting the original array.
- JavaScript – Array splice() MethodThe Array splice() method adds and/or removes array elements, overwriting the original array.
- JavaScript – Array toString() MethodThe Array toString() method returns a string with array values separated by commas, and does not change the original array.
- JavaScript – Array unshift() MethodThe Array unshift() method adds new elements to the beginning of an array, overwriting the original array.
- JavaScript – Array valueOf() MethodThe Array valueOf() method returns the value of the array (contents), and does not change the original array.
JavaScript Notes:
- When using JavaScript, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- JavaScript is a case-sensitive language; firstName is NOT the same as firstname
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
- JavaScript variables must begin with a letter, $, or _
- JavaScript variables are case sensitive (x is not the same as X)
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.