JS Array slice vs splice: What Is the Difference?
slice() copies a portion of an array without changing the original. splice() removes, adds, or replaces elements and mutates the array. Learn when to use each.
Master JavaScript from basics to advanced
slice() copies a portion of an array without changing the original. splice() removes, adds, or replaces elements and mutates the array. Learn when to use each.
Learn three ways to merge arrays in JavaScript: concat(), the spread operator, and push() with spread. Each method has different strengths for different situations.
Learn every use of the spread operator (...) with arrays: copying, merging, inserting elements, converting iterables, and passing array elements as function arguments.
The spread operator creates shallow copies. Learn what that means for nested objects and arrays, how to avoid shared reference bugs, and when to use structuredClone.
map() returns a new array. forEach() returns undefined. Learn the key differences, when to use each, and why choosing the right one makes your code cleaner.
some() checks if any element passes a test. every() checks if all elements pass. Learn how these boolean array methods work with clear examples and practical use cases.
flatMap() combines map() and flat(1) into a single method. Learn how to map and flatten in one pass with clear examples and practical use cases.
filter() creates a new array with only the elements that pass a test. Learn how to select, exclude, and refine array data with clear examples.
reduce() turns an array into a single value by running an accumulator function on every element. Learn summing, grouping, flattening, and more.
find() returns the first element that matches a condition. findIndex() returns its index. Learn how to search arrays beyond indexOf with clear examples.
sort() arranges array elements in place. Learn how default string sorting works, how to write a compare function for numbers and objects, and common pitfalls.
Destructuring unpacks array values into variables in one line. Learn the syntax, default values, skipping elements, rest patterns, and practical use cases.