Reference library
JavaScript Array References
Look up a function or method when you need it. These pages are available independently of the course and do not count toward lesson progress.
Array Operations
- How to Declare an Empty Array in JavaScript
Learn beginner-friendly ways to declare an empty array in JavaScript using modern and traditional techniques. Includes code examples and outputs.
- How to Declare an Array With Initial Values in JavaScript
Learn how to declare an array with initial values in JavaScript using multiple methods like literals, constructors, and Array.of(). Includes examples and outputs.
- How to Check the Number of Items in an Array in JavaScript
Learn the easiest and most accurate ways to check the number of elements in a JavaScript array. Beginner-friendly with examples, code, and explanations.
- How to Get the First Item in an Array in JavaScript
Learn multiple ways to retrieve the first element of an array in JavaScript. This beginner-friendly tutorial explains various techniques with examples and output.
- How to Get the Last Item in an Array in JavaScript
Learn different ways to access the last item in a JavaScript array. This beginner-friendly tutorial covers multiple methods with examples and outputs.
- How to Access an Item by Its Position in JavaScript
Learn how to access an item in a JavaScript array by its position using different beginner-friendly methods. Includes real-world examples and clear code output.
- How to Update an Item at a Specific Position in JavaScript
Learn how to change or update an element at a specific index in a JavaScript array using different methods. Beginner-friendly examples and outputs included.
- How to Add an Item to the End of an Array in JavaScript
Learn how to add items to the end of a JavaScript array using push(), length assignment, and spread syntax. Beginner-friendly examples with output included.
- How to Add an Item to the Beginning of an Array in JavaScript
Learn how to add items to the beginning of a JavaScript array using unshift(), spread operator, and manual insertion. Beginner-friendly with examples and code output.
- How to Insert an Item at a Specific Index in JavaScript
Learn how to insert an item into a JavaScript array at any specific index using splice(), slice + spread, and custom logic. Includes clear examples with output.
- How to Remove the Last Item From an Array in JavaScript
Learn beginner-friendly methods to remove the last item from a JavaScript array using pop(), slice(), and destructuring. Includes code examples and outputs.
- How to Remove the First Item From an Array in JavaScript
Learn how to remove the first element from a JavaScript array using shift(), slice(), and destructuring. Includes beginner-friendly examples and code output.
- How to Remove an Item From a Specific Position in JavaScript
Learn how to remove an item from a specific index in a JavaScript array using various methods like splice(), filter(), and slice. Includes complete examples and outputs.
- How to Remove All Items From an Array in JavaScript
Learn different ways to remove all elements from an array in JavaScript. Covers methods like setting length to zero, splice, and reassignment. Includes full examples with outputs.
- How to Copy Items Into a New Array in JavaScript
Learn different ways to copy items from one array to a new array in JavaScript. Explore methods like spread operator, slice, Array.from, and map with complete code examples and output.
- How to Combine Two or More Arrays in JavaScript
Learn how to merge multiple arrays in JavaScript using beginner-friendly techniques like concat and spread operator. See full examples with output.
- How to Split an Array Into Smaller Arrays in JavaScript
Learn different ways to split an array into smaller arrays in JavaScript. This beginner-friendly tutorial covers slice-based loops, recursion, and utility functions with examples and output.
- How to Loop Through All Items in an Array in JavaScript
Explore beginner-friendly ways to loop through all items in an array using JavaScript. Learn about for, for...of, forEach, and map loops with full examples and explanations.
- How to Transform Each Item in an Array in JavaScript
Learn multiple ways to transform every item in a JavaScript array using beginner-friendly examples. Explore map(), forEach(), and traditional loops for data transformation.
- How to Select Specific Items From an Array in JavaScript
Learn beginner-friendly ways to select specific items from an array in JavaScript. Discover how to use filter(), slice(), and index-based logic with real examples and output.
- How to Count Items That Meet a Condition in JavaScript
Learn beginner-friendly ways to count items that meet a specific condition in JavaScript using filter, reduce, and loops. Includes complete examples and output.
- How to Calculate the Sum of Array Values in JavaScript
Learn how to calculate the sum of array values in JavaScript using multiple beginner-friendly methods including reduce(), for loop, and forEach(). Includes examples and output.
- How to Check if a Value Exists in an Array in JavaScript
Learn how to check if a value exists in a JavaScript array using includes(), indexOf(), and some(). Beginner-friendly explanations with complete code and output.
- How to Find the Position of a Value in JavaScript
Learn how to find the index or position of a value in a JavaScript array using indexOf(), findIndex(), and manual loop techniques. Includes beginner-friendly examples with output.
- How to Find the Last Position of a Value in JavaScript
Learn how to find the last index of a value in a JavaScript array using lastIndexOf(), loops, and reverse traversal. Includes beginner-friendly examples and full code output.
- How to Extract a Section of an Array in JavaScript
Learn how to extract a portion of a JavaScript array using methods like slice(), splice(), and destructuring. Includes full code examples and output for beginners.
- How to Replace Part of an Array in JavaScript
Learn how to replace specific elements or sections of an array in JavaScript using splice(), direct assignment, and map(). Beginner-friendly examples with full code and output.
- How to Reverse the Order of Items in JavaScript
Learn beginner-friendly ways to reverse the order of items in a JavaScript array using reverse(), spread syntax, and manual loops. Includes complete examples and console output.
- How to Sort Items Alphabetically in JavaScript
Learn how to sort arrays alphabetically in JavaScript using sort(), localeCompare(), and case-insensitive sorting techniques. Includes beginner-friendly examples with output.
- How to Sort Numbers in Ascending Order in JavaScript
Learn how to sort an array of numbers in ascending order using JavaScript. Explore beginner-friendly methods with sort(), compare functions, and manual logic. Full examples with output included.
- How to Sort Numbers in Descending Order in JavaScript
Learn how to sort numbers in descending order using JavaScript. This beginner-friendly guide explains the correct use of sort() with a custom compare function and includes examples with output.
- How to Sort Objects by a Property in JavaScript
Learn how to sort an array of objects in JavaScript by a specific property using the sort() function. This guide includes beginner-friendly examples and step-by-step explanations.
- How to Check if All Items Meet a Condition in JavaScript
Learn how to use JavaScript's array methods to check if all elements meet a specific condition. Covers Array.every() and manual loops with clear beginner-friendly examples.
- How to Check if Any Item Meets a Condition in JavaScript
Learn how to use JavaScript methods like Array.some() and for loops to check if any item in an array meets a specific condition. Includes beginner-friendly examples and full code.
- How to Find the First Matching Item in JavaScript
Learn how to use JavaScript to find the first item in an array that meets a specific condition using methods like find() and for loops. Beginner-friendly examples included.
- How to Find the Index of a Matching Item in JavaScript
Learn how to find the index of an item in a JavaScript array that matches a condition using findIndex() and for loops. Complete examples included.
- How to Remove Duplicate Items From an Array in JavaScript
Learn multiple ways to remove duplicate items from a JavaScript array using Set, filter, indexOf, and reduce. Beginner-friendly and complete examples with outputs.
- How to Count Occurrences of a Value in JavaScript
Learn different ways to count how many times a specific value appears in a JavaScript array. Explore simple and beginner-friendly techniques using loops, filter, and reduce.
- How to Flatten a Nested Array in JavaScript
Learn beginner-friendly techniques to flatten nested arrays in JavaScript using loops, flat(), recursion, and reduce. Includes clear examples with code and output.
- How to Convert an Array to a String in JavaScript
Learn how to convert arrays into strings in JavaScript using toString(), join(), and template literals. Beginner-friendly examples with simple fruits like apple, banana, and cherry.
- How to Create an Array From a String in JavaScript
Learn beginner-friendly ways to convert a string into an array in JavaScript using split(), Array.from(), spread operator, and match(). Includes examples using simple fruit names.
- How to Create an Array From Multiple Arguments in JavaScript
Learn how to build an array from multiple values passed as arguments using JavaScript. Explore methods like Array.of(), spread operator, and function rest parameters with simple examples.
- How to Create an Array With Repeated Values in JavaScript
Learn beginner-friendly ways to create arrays filled with repeated values in JavaScript using fill(), Array.from(), loops, and more. Includes practical examples like repeating 'apple'.
- How to Create an Array With a Fixed Size in JavaScript
Learn how to create a fixed-size array in JavaScript using new Array(), Array.from(), fill(), and length property. Beginner-friendly examples included.
- How to Fill an Array With a Single Value in JavaScript
Learn beginner-friendly ways to fill a JavaScript array with a single value using fill(), Array.from(), and loops. Includes examples using apple, banana, and more.
- How to Check if a Variable Is an Array in JavaScript
Learn multiple beginner-friendly ways to check if a variable is an array in JavaScript using Array.isArray(), instanceof, and Object.prototype.toString.
- How to Compare Two Arrays for Equality in JavaScript
Learn beginner-friendly ways to compare two arrays for equality in JavaScript. Explore deep comparison techniques using loops, JSON.stringify(), and every().
- How to Find the Difference Between Two Arrays in JavaScript
Learn beginner-friendly techniques to find the difference between two arrays in JavaScript using filter(), includes(), Set, and custom comparison. Real-world examples included.
- How to Find Common Items in Two Arrays in JavaScript
Learn beginner-friendly ways to find common elements between two arrays in JavaScript using filter(), includes(), Set, and loops. Real-world fruit examples included.
- How to Shuffle the Items in an Array in JavaScript
Learn beginner-friendly ways to shuffle arrays in JavaScript using the Fisher-Yates algorithm, sort with Math.random, and reusable shuffle functions. Includes fruit examples.
- How to Convert an Array to a Set in JavaScript
Learn how to convert an array to a Set in JavaScript. Explore multiple beginner-friendly methods to remove duplicates and create unique collections using Set.
- How to Convert a Set to an Array in JavaScript
Learn beginner-friendly methods to convert a Set to an Array in JavaScript. Discover how to use spread syntax, Array.from(), and loops for effective conversion.
- How to Create a Range of Numbers as an Array in JavaScript
Learn beginner-friendly methods to generate a range of numbers as an array in JavaScript using loops, Array.from, and the spread operator. Explore step-by-step examples and code.
- How to Remove Falsy Values From an Array in JavaScript
Learn how to remove falsy values like false, 0, '', null, undefined, and NaN from an array in JavaScript using clean and beginner-friendly methods.
- How to Check if an Array Is Empty in JavaScript
Learn multiple ways to check if an array is empty in JavaScript. This guide covers array length, optional chaining, and defensive programming for beginners.
- How to Get the Maximum Value in a Numeric Array in JavaScript
Learn multiple beginner-friendly ways to find the maximum value in a numeric array in JavaScript using Math.max, reduce, loops, and spread syntax.
- How to Get the Minimum Value in a Numeric Array in JavaScript
Learn how to find the smallest number in a numeric array in JavaScript using Math.min, reduce, loops, and sorting. Beginner-friendly examples included.
- How to Clone an Array Without Reference in JavaScript
Learn multiple beginner-friendly ways to clone an array in JavaScript without maintaining reference to the original. Includes examples using spread operator, slice, and more.