Programming Languages
JavaScript
Subjective
Sep 25, 2025
What are JavaScript arrays and their methods?
Detailed Explanation
Arrays are ordered collections of elements in JavaScript.
Creating Arrays:
const arr1 = [1, 2, 3];
const arr2 = new Array(1, 2, 3);
Common Methods:
Mutating methods:
- push() - add to end
- pop() - remove from end
- shift() - remove from start
- unshift() - add to start
- splice() - add/remove elements
- sort() - sort elements
- reverse() - reverse order
Non-mutating methods:
- concat() - join arrays
- slice() - extract portion
- indexOf() - find index
- includes() - check existence
Iteration methods:
- forEach() - execute function for each
- map() - transform elements
- filter() - filter elements
- reduce() - reduce to single value
- find() - find first match
- some() - test if any match
- every() - test if all match
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts