JavaScript Methods

Pascual Vila
Senior Frontend Engineer // Code Syllabus
Arrays are one of the most fundamental data structures in JavaScript. To interact with arrays efficiently, JS provides a wide array of built-in Methods. Let's break down the most essential ones.
Mutation: push & pop
Methods like .push() and .pop() mutate the original array. This means they change the data exactly where it lives in memory.
Use push(item) to add an item to the end, and pop() to remove the last item.
Transformation: map
The .map() method allows you to take an array, pass a function that operates on each item, and receive a brand new array containing the results. It is the cornerstone of rendering lists in frameworks like React.
Selection: filter
If you need to extract specific elements based on a condition, .filter() is your tool. Like map, it does not modify the original array. The callback function must return a boolean (true to keep the item, false to discard it).
View Full Documentation Transcript+
This section covers detailed logic regarding mutability vs immutability. In modern frontend architecture (like React/Redux), mutating arrays directly with push/pop is often discouraged in favor of spreading `[...arr, newItem]` or using map/filter to ensure components rerender predictably based on reference changes.