Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Array Methods – map, filter, redu | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 19 of 55

·javascript

Array Methods – map, filter, reduce, find, some, every

12 mins

Course progress35%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • All methods **return a new array** (except `reduce` which returns a single value).
  • Do not mutate the original array inside callbacks unless intentionally.
  • `reduce` can be used to build **objects**, **maps**, or **strings**.

Functional array helpers make data transformation declarative.

const nums = [1,2,3,4,5];
const evens = nums.filter(n=>n%2===0); // [2,4]
const squares = nums.map(n=>n*n);      // [1,4,9,16,25]
const sum = nums.reduce((a,b)=>a+b,0); // 15

Other useful methods:

  • find – first element matching a predicate.
  • some – any element matches?
  • every – all elements match?

Example: Group objects by property

const books = [
  {genre:'fiction',title:'A'},
  {genre:'nonfiction',title:'B'},
  {genre:'fiction',title:'C'}
];
const byGenre = books.reduce((acc,b)=>{
  (acc[b.genre] = acc[b.genre] || []).push(b);
  return acc;
},{});
console.log(byGenre);
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonRegular Expressions – `RegExp` & String MethodsContinue to lesson 20Object Literals, Shorthand & DestructuringBack to JavaScript Course curriculum