🔧 AI Nachrichten ChatGPT showing blank screen [Fix](05.09.2026 um 19:55 Uhr)
⚠️ Malware / Trojaner / VirenSofort deinstallieren: Diese 19 Browser-Erweiterungen sind mit Malware verseucht(06.09.2026 um 08:00 Uhr)
🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)
🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)
⚠️ Malware / Trojaner / VirenLumma Stealer – dllhost.exe Hollowing, C2 Domains & Payload Extraction(01.09.2026 um 17:19 Uhr)
🔧 AI Nachrichten Simcha Kosman AMA: Owning ChatGPT's Secure Sandbox(03.09.2026 um 07:41 Uhr)
⚠️ Malware / Trojaner / VirenThe Gentlemen Ransomware Analysis: Go Obfuscated(04.09.2026 um 12:05 Uhr)
🕵️ Reverse EngineeringRelease OpenPetya v2.0.0 · iss4cf0ng/OpenPetya(06.09.2026 um 08:38 Uhr)
🕵️ SicherheitslückenSecurity Vulnerability in a Voting System(04.09.2026 um 13:09 Uhr)
🔧 AI Nachrichten ChatGPT showing blank screen [Fix](05.09.2026 um 19:55 Uhr)
⚠️ Malware / Trojaner / VirenSofort deinstallieren: Diese 19 Browser-Erweiterungen sind mit Malware verseucht(06.09.2026 um 08:00 Uhr)
🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)
🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)
⚠️ Malware / Trojaner / VirenLumma Stealer – dllhost.exe Hollowing, C2 Domains & Payload Extraction(01.09.2026 um 17:19 Uhr)
🔧 AI Nachrichten Simcha Kosman AMA: Owning ChatGPT's Secure Sandbox(03.09.2026 um 07:41 Uhr)
⚠️ Malware / Trojaner / VirenThe Gentlemen Ransomware Analysis: Go Obfuscated(04.09.2026 um 12:05 Uhr)
🕵️ Reverse EngineeringRelease OpenPetya v2.0.0 · iss4cf0ng/OpenPetya(06.09.2026 um 08:38 Uhr)
🕵️ SicherheitslückenSecurity Vulnerability in a Voting System(04.09.2026 um 13:09 Uhr)

🔧 Programmierung 🕛 kürzlich 5 Min Lesezeit
0

JavaScript Array Methods: The Complete Visual Guide

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




JavaScript Array Methods: The Complete Visual Guide



Master these methods and you'll write 50% less code.






The Map: Array Method Categories






CODE
┌─────────────────────────────────────────┐
│ JavaScript Arrays │
├─────────┬──────────┬──────────┬─────────┤
│ Iterate │ Transform │ Filter │ Reduce │
├─────────┼──────────┼──────────┼─────────┤
│ forEach │ map │ filter │ reduce │
│ for...of │ flatMap │ find │ some │
│ │ sort │ findIndex│ every │
│ │ reverse │ includes │ join │
│ │ slice │ splice │ toString│
├─────────┼──────────┼──────────┼─────────┤
│ │ │ │ │
│ "Do" │ "New" │ "Pick" │ "Result"│
└─────────┴──────────┴──────────┴─────────┘









1. map() — Transform Every Element






CODE
const numbers = [1, 2, 3, 4, 5];

// Double every number
numbers.map(n => n * 2); // [2, 4, 6, 8, 10]

// Extract property from objects
const users = [{ name: 'Alex', age: 30 }, { name: 'Sam', age: 25 }];
users.map(u => u.name); // ['Alex', 'Sam']

// Convert types
const strings = ['1', '2', '3'];
strings.map(Number); // [1, 2, 3]









2. filter() — Keep Elements That Pass a Test






CODE
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

// Even numbers only
numbers.filter(n => n % 2 === 0); // [2, 4, 6, 8, 10]

// Active users
const users = [
{ name: 'Alex', active: true },
{ name: 'Bob', active: false },
{ name: 'Charlie', active: true },
];
users.filter(u => u.active); // [{ name: 'Alex' }, { name: 'Charlie' }]

// Remove falsy values
const mixed = [0, 1, '', 'hello', null, undefined, false, 42];
mixed.filter(Boolean); // [1, 'hello', 42]









3. reduce() — Transform Array Into Anything






CODE
const numbers = [1, 2, 3, 4, 5];

// Sum
numbers.reduce((sum, n) => sum + n, 0); // 15

// Count occurrences
const fruits = ['apple', 'banana', 'apple', 'cherry', 'banana', 'apple'];
fruits.reduce((count, fruit) => {
count[fruit] = (count[fruit] || 0) + 1;
return count;
}, {});
// { apple: 3, banana: 2, cherry: 1 }

// Flatten (use flat() instead though)
const nested = [[1, 2], [3, 4], [5]];
nested.reduce((flat, arr) => [...flat, ...arr], []); // [1, 2, 3, 4, 5]

// Group by property
const people = [
{ name: 'Alex', dept: 'Engineering' },
{ name: 'Sam', dept: 'Marketing' },
{ name: 'Charlie', dept: 'Engineering' },
];
people.reduce((groups, person) => {
(groups[person.dept] ??= []).push(person);
return groups;
}, {});
// { Engineering: [...], Marketing: [...] }









4. find() and findIndex()






CODE
const users = [
{ id: 1, name: 'Alex', role: 'admin' },
{ id: 2, name: 'Sam', role: 'user' },
{ id: 3, name: 'Charlie', role: 'admin' },
];

// Find first admin
users.find(u => u.role === 'admin'); // { id: 1, name: 'Alex', role: 'admin' }

// Find by id
users.find(u => u.id === 2); // { id: 2, name: 'Sam', role: 'user' }

// Index of first admin
users.findIndex(u => u.role === 'admin'); // 0

// Not found → undefined
users.find(u => u.id === 999); // undefined









5. some() and every()






CODE
const numbers = [2, 4, 6, 8, 10];

// Is at least one even? (always true here, but example)
numbers.some(n => n > 5); // true

// Are ALL numbers even?
numbers.every(n => n % 2 === 0); // true

// Real use case: form validation
const form = { email: '[email protected]', password: 'abc123', name: '' };

const isValid = Object.values(form).every(Boolean); // false (name is empty)

// Real use case: permissions check
const userPermissions = ['read', 'write'];
const hasWrite = userPermissions.includes('write'); // true
const isAdmin = userPermissions.includes('admin'); // false









6. sort() — Sort Elements






CODE
const nums = [3, 1, 4, 1, 5, 9, 2, 6];
nums.sort((a, b) => a - b); // [1, 1, 2, 3, 4, 5, 6, 9] ascending
nums.sort((a, b) => b - a); // [9, 6, 5, 4, 3, 2, 1, 1] descending

// Sort objects by property
const users = [
{ name: 'Charlie', age: 25 },
{ name: 'Alex', age: 30 },
{ name: 'Sam', age: 28 },
];

users.sort((a, b) => a.age - b); // Youngest first
users.sort((a, b) => a.name.localeCompare(b.name)); // Alphabetical

// ⚠️ sort() mutates the original array!
// Use .toSorted() (ES2023) for a new array:
const sorted = nums.toSorted((a, b) => a - b);









7. flat() and flatMap()






CODE
// Flatten nested arrays
const nested = [1, [2, 3], [4, [5, 6]]];
nested.flat(); // [1, 2, 3, 4, [5, 6]] (one level)
nested.flat(Infinity); // [1, 2, 3, 4, 5, 6] (all levels)

// flatMap = map + flat (one step)
const sentences = ['hello world', 'foo bar baz'];

sentences.flatMap(s => s.split(' '));
// ['hello', 'world', 'foo', 'bar', 'baz']

// Practical: Filter + Transform in one step
const users = [
{ name: 'Alex', posts: 10 },
{ name: 'Bob', posts: 0 },
{ name: 'Charlie', posts: 5 },
];

users.flatMap(u => u.posts > 0 ? [u.name] : []);
// ['Alex', 'Charlie'] (filter AND extract)









8. slice() and splice()






CODE
const arr = [1, 2, 3, 4, 5];

// slice: Extract without modifying original
arr.slice(1, 3); // [2, 3]
arr.slice(-2); // [4, 5]
arr.slice(2); // [3, 4, 5]
// arr is still [1, 2, 3, 4, 5]

// splice: Modify original (remove, insert, replace)
const removed = arr.splice(1, 2); // Remove 2 elements from index 1
// arr is now [1, 4, 5], removed is [2, 3]

// Insert at index
arr.splice(1, 0, 2, 3); // Insert 2, 3 at index 1
// arr is now [1, 2, 3, 4, 5]









9. includes() — Simple Existence Check






CODE
const colors = ['red', 'green', 'blue'];
colors.includes('green'); // true
colors.includes('yellow'); // false

// More readable than indexOf:
// Old: colors.indexOf('green') !== -1
// New: colors.includes('green')









10. Chaining Methods






CODE
const users = [
{ name: 'Alex', age: 30, role: 'admin', active: true },
{ name: 'Bob', age: 20, role: 'user', active: false },
{ name: 'Charlie', age: 25, role: 'user', active: true },
{ name: 'Diana', age: 35, role: 'admin', active: true },
];

// Get names of active users over 25, sorted by age
const result = users
.filter(u => u.active) // Keep active
.filter(u => u.age > 25) // Keep over 25
.sort((a, b) => a.age - b) // Sort by age
.map(u => u.name); // Extract names

// ['Alex', 'Diana']

// Average age of active admins
const avgAge = users
.filter(u => u.role === 'admin' && u.active)
.map(u => u.age)
.reduce((sum, age, _, arr) => sum + age / arr.length, 0);

// 32.5









Quick Reference




























































































Method Returns Mutates? Use Case
map() New array No Transform elements
filter() New array No Keep matching elements
reduce() Any value No Accumulate into one value
find() Element or undefined No Find first match
findIndex() Index or -1 No Find index of first match
some() Boolean No At least one matches?
every() Boolean No All match?
includes() Boolean No Contains value?
sort() Same array Yes Sort elements
flat() New array No Flatten nested arrays
flatMap() New array No Map + flatten
slice() New array No Extract portion
splice() Removed elements Yes Insert/remove/replace





Which array method do you use most? Any I missed?



Follow @armorbreak for more JavaScript content.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 47%
🟡 In Evaluierung 25%
🟢 Keine Auswirkung 15%
Spannende Innovation 13%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
2 Quellen
GenAI Workflows für Social Media Content
1 Quelle
ChatGPT showing blank screen [Fix]
1 Quelle
Sofort deinstallieren: Diese 19 Browser-Erweiterungen sind mit Malware verseucht
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten JavaScript Array Methods: The Complete Visual Guide

Thematisch verwandte Begriffe: JavaScript, Array, Methods, Complete · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...