Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Callbacks, Promises & Async – await Explained

Callbacks, Promises & Async – await: Callbacks → Callback Hell → Promises → Promise Chaining → Async/Await → IIFE Synchronous vs Asynchronous Synchronous Code runs line by line. Each instruction waits for the previous one to finish …

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Callbacks, Promises & Async – await:



Callbacks → Callback Hell → Promises → Promise Chaining → Async/Await → IIFE



Synchronous vs Asynchronous



Synchronous

Code runs line by line. Each instruction waits for the previous one to finish before moving on. Can block the UI if a task is slow.

Asynchronous

Slow tasks (timers, API calls) are handed off. Remaining code keeps running. Result is handled later when ready.

// Async demo with setTimeout

console.log("one");

console.log("two");



setTimeout(() => {

console.log("hello"); // runs after 4s

}, 4000);



console.log("three");

console.log("four");



// Output: one → two → three → four → hello



Callbacks

A callback is a function passed as an argument to another function and called inside it. It's how JS handles "do this, then do that" logic.

function sum(a, b) {

console.log(a + b);

}



function calculator(a, b, sumCallback) {

sumCallback(a, b); // sum is called here

}



calculator(1, 2, sum); // Output: 3

Callback Hell (Pyramid of Doom)

When callbacks are nested inside each other to sequence async tasks, code becomes deeply indented and hard to read/maintain. This is called Callback Hell.

function getData(dataId, getNextData) {

setTimeout(() => {

console.log("data", dataId);

if (getNextData) getNextData();

}, 2000);

}



// Callback Hell ↓

getData(1, () => {

console.log("getting data2...");

getData(2, () => {

console.log("getting data3...");

getData(3, () => {

console.log("getting data4...");

getData(4);

});

});

});



The deeper the nesting, the harder to read, debug, and maintain. Promises solve this.

Promises A Promise is a JS object representing the eventual completion or failure of an async task. It takes a function with two handlers: resolve (success) and reject (failure).

Pending

Result is undefined. Task still in progress.

Fulfilled

resolve(value) was called. Task succeeded.

Rejected

reject(error) was called. Task failed.



// Creating a Promise

const getPromise = () => {

return new Promise((resolve, reject) => {

console.log("I am a promise");

resolve("success"); // OR

// reject("error");

});

};



// Consuming a Promise

let promise = getPromise();



promise.then((res) => {

console.log("Fulfilled:", res); // runs on resolve

});



promise.catch((err) => {

console.log("Rejected:", err); // runs on reject

});

resolve and reject are callbacks provided by JS — you just call them. If you reject without .catch(), you get an Uncaught (in promise) error in console.



Promise Chaining

Instead of nesting, return a new Promise inside .then() and chain another .then(). This keeps code flat and readable — the fix for callback hell.

function getData(dataId) {

return new Promise((resolve, reject) => {

setTimeout(() => {

console.log("data", dataId);

resolve("success");

}, 3000);

});

}



// Promise Chain (clean & flat!)

getData(1)

.then((res) => { return getData(2); })

.then((res) => { return getData(3); })

.then((res) => { console.log(res); });

Async / Await

async before a function makes it always return a Promise.



await pauses execution inside the async function until a Promise settles — making async code look and read like synchronous code.

function getData(dataId) {

return new Promise((resolve, reject) => {

setTimeout(() => {

console.log("data", dataId);

resolve("success");

}, 2000);

});

}



// Async-Await (cleanest way!)

async function getAllData() {

console.log("getting data1...");

await getData(1); // waits here

console.log("getting data2...");

await getData(2); // then waits here

console.log("getting data3...");

await getData(3);

}

getAllData();

IIFE — Immediately Invoked Function Expression

An IIFE is a function that runs immediately as soon as it is defined. Useful to run async code at the top level without wrapping it in a named function.

// Regular IIFE

(function () {

// runs immediately

})();



// Arrow IIFE

(() => {

// runs immediately

})();



// Async IIFE — most common use case

(async () => {

console.log("getting data1...");

await getData(1);

console.log("getting data2...");

await getData(2);

})();

Pattern: (func)() — wrap function in () to make it an expression, then call it with () immediately.



Summary

Callbacks → Callback Hell problem → Promises fix it → Promise Chaining improves readability → Async/Await makes it look synchronous → IIFE lets you run async code immediately

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Vulnerability Remediation & Verification
Syntax validiert (0 Fehler)
title: Detect Exploitation - Callbacks, Promises & Async – await Explained
id: f98c5223-426f-4d78-8527-c63fd329eb1a
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-27
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-27"
        description = "YARA Signature for "
    strings:
        $str = "Callbacks, Promises & Async – " ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Callbacks Promises  Async  await Explain")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Callbacks Promises  Async  await Explain*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Callbacks Promises  Async  await Explain"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Analyse für identifizierte Bedrohung auf Basis von Live-CTI (ENISA EUVD): CVSS 0.0 · EPSS 0.0% · CISA KEV: nein. Handlungsableitung aus den verlinkten Hersteller-Quellen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Callbacks, Promises & Async – await Explained

Thematisch verwandte Begriffe: Callbacks, Promises, Async, await · 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 ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-100739 | A vulnerability was detected in mathurvishal CloudClassroom-PHP-Project…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag