Hackforge Academy

Category: javascript

what is array

Published on 16 Jul 2026

Explanation

An array is a collection of multiple values stored in a single variable. Each value is accessed using its index.

Code:

const fruits = ['Apple', 'Banana', 'Orange'];
console.log(fruits[0]);

Explanation

The push() and pop() methods add and remove elements from the end of an array.

Code:

let numbers = [10, 20];
numbers.push(30);
numbers.pop();

Explanation

The shift() and unshift() methods remove and add elements at the beginning of an array.

Code:

let colors = ['Red', 'Blue'];
colors.unshift('Green');
colors.shift();

Explanation

The map() method creates a new array by transforming each element.

Code:

const nums = [1,2,3];
const doubled = nums.map(n => n * 2);

Explanation

The filter() method returns elements that satisfy a given condition.

Code:

const ages = [12,18,25];
const adults = ages.filter(age => age >= 18);

๐Ÿš€ Learn Spring Boot with real-world projects

๐Ÿ’ก Build REST APIs step by step

๐Ÿง  Improve backend development skills

๐ŸŽฏ Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

๐Ÿ

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
โš›๏ธ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
โ˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community