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

Day 5: Understanding Functions in JavaScript

Introduction Welcome to Day 5 of your JavaScript journey! Yesterday, we explored control structures, learning how to make decisions and repeat actions in our code. Today, we'll dive into functions, which are essential for organizing and…

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




Introduction



Welcome to Day 5 of your JavaScript journey! Yesterday, we explored control structures, learning how to make decisions and repeat actions in our code. Today, we'll dive into functions, which are essential for organizing and reusing code in JavaScript.



please subscribe to my YouTube channel to support my channel and get more web development tutorials.






Functions



Functions are blocks of code designed to perform a particular task. They help to make your code more modular, reusable, and easier to read.



1. Function Declaration



A function declaration defines a function with the specified parameters.



Syntax:




function functionName(parameters) {
// code to be executed
}






Example:




function greet(name) {
console.log("Hello, " + name + "!");
}

greet("Alice"); // Output: Hello, Alice!
greet("Bob"); // Output: Hello, Bob!






2. Function Expression



A function expression defines a function as part of an expression. It can be anonymous or named.



Syntax:




const functionName = function(parameters) {
// code to be executed
};






Example:




const greet = function(name) {
console.log("Hello, " + name + "!");
};

greet("Charlie"); // Output: Hello, Charlie!






3. Arrow Functions



Arrow functions provide a shorter syntax for writing functions. They are anonymous and cannot be used as constructors.



Syntax:




const functionName = (parameters) => {
// code to be executed
};






Example:




const greet = (name) => {
console.log("Hello, " + name + "!");
};

greet("Dave"); // Output: Hello, Dave!









Parameters and Arguments



Functions can accept parameters, which are placeholders for the values you pass to the function (arguments).



Example:




function add(a, b) {
return a + b;
}

let sum = add(5, 3);
console.log(sum); // Output: 8









Return Statement



The return statement specifies the value to be returned by the function.



Example:




function multiply(a, b) {
return a * b;
}

let product = multiply(4, 7);
console.log(product); // Output: 28









Function Scope



Variables declared inside a function are local to that function and cannot be accessed outside it.



Example:




function scopeTest() {
let localVar = "I am local";
console.log(localVar); // Output: I am local
}

scopeTest();
// console.log(localVar); // Error: localVar is not defined









Practical Examples



Example 1: Function to calculate the area of a rectangle




function calculateArea(width, height) {
return width * height;
}

let area = calculateArea(5, 10);
console.log("Area:", area); // Output: Area: 50






Example 2: Function to find the maximum of two numbers




function findMax(a, b) {
if (a > b) {
return a;
} else {
return b;
}
}

let max = findMax(8, 12);
console.log("Max:", max); // Output: Max: 12






Example 3: Arrow function to check if a number is even




const isEven = (number) => {
return number % 2 === 0;
};

console.log(isEven(4)); // Output: true
console.log(isEven(7)); // Output: false









Practice Activities



1. Practice Code:




  • Write functions using function declarations, function expressions, and arrow functions.

  • Create functions with parameters and return values.



2. Mini Project:




  • Create a simple script that takes a number from the user and uses a function to determine if the number is prime.



Example:




function isPrime(number) {
if (number <= 1) {
return false;
}
for (let i = 2; i < number; i++) {
if (number % i === 0) {
return false;
}
}
return true;
}

let num = parseInt(prompt("Enter a number:"));
if (isPrime(num)) {
console.log(num + " is a prime number.");
} else {
console.log(num + " is not a prime number.");
}
// If the user enters 5, the output will be:
// 5 is a prime number.









Summary



Today, we explored functions in JavaScript. We learned about function declarations, function expressions, and arrow functions. We also covered parameters, arguments, return statements, and function scope. Understanding functions is crucial for creating modular and reusable code.



Stay tuned for Day 6, where we'll dive into arrays and their methods in JavaScript!



Feel free to leave your comments or questions below. If you found this guide helpful, please share it with your peers and follow me for more web development tutorials. Happy coding!






Follow and Subscribe:



1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Vulnerability Remediation & Verification
Syntax validiert (0 Fehler)
title: Detect Exploitation - Day 5: Understanding Functions in JavaScript
id: fd7f4635-47a9-4913-bb4e-e9461162889b
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
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-25"
        description = "YARA Signature for "
    strings:
        $str = "Day 5: Understanding Functions" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Day 5 Understanding Functions in JavaScr")
| 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: "*Day 5 Understanding Functions in JavaScr*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Day 5 Understanding Functions in JavaScr"
| 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:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Day 5: Understanding Functions in JavaSc.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ 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.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Day 5: Understanding Functions in JavaScript

Thematisch verwandte Begriffe: Understanding, Functions, JavaScript · 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 ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97898 | Insecure Direct Object Reference / missing object-level authorization in…
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