Operatoren sind Symbole in JavaScript, mit denen Werte verarbeitet, verglichen oder verändert werden können. Sie führen also bestimmte Aktionen aus, wie Rechnen, Vergleiche oder logische Entscheidungen.
Strings
Grundrechenarten
In-/Dekrement
Zuweisungen
Vergleichen
Logische
Bitweise
Sonstige
1. Strings
Operator
Bedeutung
Beispiel
Ergebnis
+
Verkettung
"Hello " + "World"
"Hello World"
+=
Anhängen
let a="Hi"; a+="!"
"Hi!"
2. Grundrechenarten
Operator
Bedeutung
Beispiel
Ergebnis
+
Addition (! ist 1 Wert ein string wird verkettet !)
5 + 3
8
-
Subtraktion
5 - 3
2
*
Multiplikation
5 * 3
15
/
Division
6 / 3
2
%
Modulo (Rest nach Division)
7 % 3
1
**
Potenz
2 ** 3
8
3. Inkrement und Dekrement
Operator
Typ
Beispiel
Ergebnis
++x
Präfix (erst erhöhen)
x=5; ++x
6
x++
Postfix (erst nutzen, dann erhöhen)
x=5; x++
nutzt 5, ist danach 6
--x
Präfix (erst senken)
y=5; --y
4
x--
Postfix (erst nutzen, dann senken)
y=5; y--
nutzt 5, ist danach 4
4. Zuweisungen
Wird jeder Zeile let x = 10 voraussetzt, gilt:
Operator
Bedeutung
Beispiel
Ergebnis
=
Wert zuweisen
x = 5
x = 5
+=
Addieren & zuweisen
x += 2
x = 12
-=
Subtrahieren & zuweisen
x -= 2
x = 8
*=
Multiplizieren & zuweisen
x *= 3
x = 30
/=
Dividieren & zuweisen
x /= 2
x = 5
%=
Modulo & zuweisen
x %= 2
x = 0
**=
Potenz & zuweisen
x **= 2
x = 100
5. Vergleichen
Operator
Bedeutung
Beispiel
Ergebnis
==
Gleich (Typ egal)
5 == "5"
✅
!=
Ungleich
5 != "5"
❌
===
Streng gleich (Typ + Wert!)
5 === "5"
❌
!==
Streng ungleich
5 !== "5"
✅
>
Größer als
7 > 3
✅
<
Kleiner als
3 < 7
✅
>=
Größer/gleich
3 >= 3
✅
<=
Kleiner/gleich
2 <= 5
✅
6. Logische Operatoren
Operator
Bedeutung
Beispiel
Ergebnis
&&
UND
true && false
false
||
ODER
true || false 0 || 20
true 20
!
NICHT
!true
false
??
liefert rechten Wert nur, wenn der Linke null oder undefined ist; verwendet für default-Werte
Darf die Webseite unterschiedliche Cookies, z.B. um zu Erkennen ob du schonmal auf meiner Seite gewesen bist, auf deinem Gerät speichern? Durck Klicken auf "Okay" erklärst du dich damit einverstanden. Unter "Einstellungen" kannst du selber festlegen, welche Cookies gesetzt werden dürfen.Hier geht's zur Datenschutzerklärung
Diese Website verwendet Cookies, um Ihre Erfahrung beim Navigieren durch die Website zu verbessern. Von diesen werden die nach Bedarf kategorisierten Cookies in Ihrem Browser gespeichert, da sie für das Funktionieren der Grundfunktionen der Website unerlässlich sind. Wir verwenden auch Cookies von Drittanbietern, die uns helfen zu analysieren und zu verstehen, wie Sie diese Website nutzen. Diese Cookies werden nur mit Ihrer Zustimmung in Ihrem Browser gespeichert. Sie haben auch die Möglichkeit, diese Cookies abzulehnen. Wenn Sie sich jedoch von einigen dieser Cookies abmelden, kann dies Ihr Surferlebnis beeinträchtigen.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Dauer
Beschreibung
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.