TGViewer
Web Development - HTML, CSS & JavaScript Web Development - HTML, CSS & JavaScript @javascript_courses ยท 55.7K subscribers
Post #3178 4.09K
โœ… JavaScript Arrays, Objects Array Methods ๐Ÿ“ฆ๐Ÿง 

Understanding how arrays and objects work helps you organize, transform, and analyze data in JavaScript. Here's a quick and clear breakdown:

1๏ธโƒฃ Arrays in JavaScript
An array stores a list of values.
let fruits = ["apple", "banana", "mango"];
console.log(fruits[1]); // banana
โ–ถ๏ธ This creates an array of fruits and prints the second fruit (banana), since arrays start at index 0.

2๏ธโƒฃ Objects in JavaScript
Objects hold keyโ€“value pairs.
let user = {
name: "Riya",
age: 25,
isAdmin: false
};

console.log(user.name); // Riya
console.log(user["age"]); // 25
โ–ถ๏ธ This object represents a user. You can access values using dot (.) or bracket ([]) notation.

3๏ธโƒฃ Array Methods โ€“ map, filter, reduce

๐Ÿ”น map() โ€“ Creates a new array by applying a function to each item
let nums = [1, 2, 3];
let doubled = nums.map(n => n * 2);
console.log(doubled); // [2, 4, 6]
โ–ถ๏ธ This multiplies each number by 2 and returns a new array.

๐Ÿ”น filter() โ€“ Returns a new array with items that match a condition
let ages = [18, 22, 15, 30];
let adults = ages.filter(age => age >= 18);
console.log(adults); // [18, 22, 30]
โ–ถ๏ธ This filters out all ages below 18.

๐Ÿ”น reduce() โ€“ Reduces the array to a single value
let prices = [100, 200, 300];
let total = prices.reduce((acc, price) => acc + price, 0);
console.log(total); // 600
โ–ถ๏ธ This adds all prices together to get the total sum.

๐Ÿ’ก Extra Notes:
โ€ข map() โ†’ transforms items
โ€ข filter() โ†’ keeps matching items
โ€ข reduce() โ†’ combines all items into one result

๐ŸŽฏ Practice Challenge:
โ€ข Create an array of numbers
โ€ข Use map() to square each number
โ€ข Use filter() to keep only even squares
โ€ข Use reduce() to add them all up

๐Ÿ’ฌ Tap โค๏ธ for more!
  • โค 12
More from @javascript_courses
  1. Oct 9, 2026๐Ÿ‡ฎ๐Ÿ‡ณ ๐—š๐—ข๐—ฉ๐—˜๐—ฅ๐—ก๐— ๐—˜๐—ก๐—ง ๐—ข๐—™ ๐—œ๐—ก๐——๐—œ๐—” โ€” ๐—”๐—œ๐—–๐—ง๐—˜ ๐—œ๐—ก๐—ง๐—˜๐—ฅ๐—ก๐—ฆ๐—›๐—œ๐—ฃ๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ ๐Ÿš€โ€ฆ
  2. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  3. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Oct 4, 2026DSA Handwritten Notes
  6. Sep 28, 2026To learn web design and development from basic to advanced levels, you can follow these stโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’