-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
JS Basics
JS Variables & Operators
JS Data Types & Conversion
JS Numbers & Math
JS Strings
JS Dates
JS Arrays
JS Control Flow
JS Loops & Iteration
JS Functions
JS Functions
Function Definitions
Function Parameters
Function Invocation
Function Call
Function Apply
Function Bind
Function Closures
JS Arrow Function
JS Objects
JS Objects
JS Object Properties
JS Object Methods
JS Object Display
JS Object Constructors
Object Definitions
Object Get / Set
Object Prototypes
Object Protection
JS Classes & Modules
JS Async Programming
JS Advanced
JS Destructuring
JS Bitwise
JS RegExp
JS Precedence
JS Errors
JS Scope
JS Hoisting
JS Strict Mode
JS this Keyword
JS HTML DOM
DOM Intro
DOM Methods
DOM Document
DOM Elements
DOM HTML
DOM Forms
DOM CSS
DOM Animations
DOM Events
DOM Event Listener
DOM Navigation
DOM Nodes
DOM Collections
DOM Node Lists
JS BOM (Browser Object Model)
JS Web APIs
Web API Intro
Web Validation API
Web History API
Web Storage API
Web Worker API
Web Fetch API
Web Geolocation API
JS AJAX
AJAX Intro
AJAX XMLHttp
AJAX Request
AJAX Response
AJAX XML File
AJAX PHP
AJAX ASP
AJAX Database
AJAX Applications
AJAX Examples
JS JSON
JSON Intro
JSON Syntax
JSON vs XML
JSON Data Types
JSON Parse
JSON Stringify
JSON Objects
JSON Arrays
JSON Server
JSON PHP
JSON HTML
JSON JSONP
JS Graphics & Charts
JavaScript provides a wide range of built-in methods to manipulate arrays efficiently — from adding/removing items to looping and transforming data.
These methods make array operations cleaner, shorter, and more expressive.
Method | Description | Example |
---|---|---|
push() |
Adds item(s) to the end of an array | arr.push("Orange") |
pop() |
Removes and returns last item | arr.pop() |
shift() |
Removes and returns first item | arr.shift() |
unshift() |
Adds item(s) to the beginning of an array | arr.unshift("Lemon") |
splice() |
Adds/removes items at specific index | arr.splice(1, 1) |
slice() |
Returns selected elements (no change to original) | arr.slice(1, 3) |
concat() |
Combines two arrays | arr1.concat(arr2) |
join() |
Converts array to string with separator | arr.join(", ") |
indexOf() |
Finds index of an element | arr.indexOf("Apple") |
includes() |
Checks if value exists | arr.includes("Mango") |
forEach() |
Executes function on each item (no return) | arr.forEach(fn) |
map() |
Transforms array, returns new array | arr.map(x => x * 2) |
filter() |
Filters elements based on condition | arr.filter(x => x > 10) |
reduce() |
Reduces array to a single value | arr.reduce((a, b) => a + b) |
find() |
Finds the first element that satisfies a condition | arr.find(x => x > 10) |
sort() |
Sorts array (default is lexicographic) | arr.sort() |
reverse() |
Reverses array elements | arr.reverse() |
let numbers = [10, 20, 30, 40, 50];
// Map
let doubled = numbers.map(n => n * 2); // [20, 40, 60, 80, 100]
// Filter
let above30 = numbers.filter(n => n > 30); // [40, 50]
// Reduce
let sum = numbers.reduce((a, b) => a + b); // 150
// Find
let firstAbove25 = numbers.find(n => n > 25); // 30
Q1. How do you double all values in an array using a method?
Q2. Which method allows you to filter numbers greater than 50 in an array?
Q3. How do you find the sum of all numbers in an array?
Q4. Which method runs a function on each item but does not return a new array?
Q5. How do you remove the last element of an array?
Q6. What method is used to sort an array alphabetically?
Q7. How do you join elements of an array into a string separated by dashes (-
)?
Q8. What method returns the index of a given value in an array?
Q9. How can you combine two arrays without modifying the original ones?
Q10. How do you reverse the order of elements in an array?
JS Basics
JS Variables & Operators
JS Data Types & Conversion
JS Numbers & Math
JS Strings
JS Dates
JS Arrays
JS Control Flow
JS Loops & Iteration
JS Functions
JS Functions
Function Definitions
Function Parameters
Function Invocation
Function Call
Function Apply
Function Bind
Function Closures
JS Arrow Function
JS Objects
JS Objects
JS Object Properties
JS Object Methods
JS Object Display
JS Object Constructors
Object Definitions
Object Get / Set
Object Prototypes
Object Protection
JS Classes & Modules
JS Async Programming
JS Advanced
JS Destructuring
JS Bitwise
JS RegExp
JS Precedence
JS Errors
JS Scope
JS Hoisting
JS Strict Mode
JS this Keyword
JS HTML DOM
DOM Intro
DOM Methods
DOM Document
DOM Elements
DOM HTML
DOM Forms
DOM CSS
DOM Animations
DOM Events
DOM Event Listener
DOM Navigation
DOM Nodes
DOM Collections
DOM Node Lists
JS BOM (Browser Object Model)
JS Web APIs
Web API Intro
Web Validation API
Web History API
Web Storage API
Web Worker API
Web Fetch API
Web Geolocation API
JS AJAX
AJAX Intro
AJAX XMLHttp
AJAX Request
AJAX Response
AJAX XML File
AJAX PHP
AJAX ASP
AJAX Database
AJAX Applications
AJAX Examples
JS JSON
JSON Intro
JSON Syntax
JSON vs XML
JSON Data Types
JSON Parse
JSON Stringify
JSON Objects
JSON Arrays
JSON Server
JSON PHP
JSON HTML
JSON JSONP
JS Graphics & Charts