Math Objekte
- Home
- Tutorials
- HTML/Web
- Javascript Tutorial
- Math Objekte
Beginnen wir mit einem kleinen Ausschnitt aus Wikipedia
Das Math Objekt beinhaltet verschiedene Mathemtische Konstanten(z.B. ?) und funktionen(z.B. cosinus). (Das Math Objekt hat keinen Konstruktor - Array und Date haben einen(dazu mehr in den folgenden Tutorials)).
Math Objekte
Property | Returned value rounded to 5 digits | Description |
---|---|---|
Math.E | 2.7183 | e: Natural logarithm base |
Math.LN2 | 0.69315 | Natural logarithm of 2 |
Math.LN10 | 2.3026 | Natural logarithm of 10 |
Math.LOG2E | 1.4427 | Logarithm to the base 2 of e |
Math.LOG10E | 0.43429 | Logarithm to the base 10 of e |
Math.PI | 3.14159 | ?: circumference/diameter of a circle |
Math.SQRT1_2 | 0.70711 | Square root of ½ |
Math.SQRT2 | 1.4142 | Square root of 2 |
Example | Returned value rounded to 5 digits | Description |
---|---|---|
Math.abs(-2.3) | 2.3 | Absolute value: (x < 0) ? -x : x |
Math.acos(Math.SQRT1_2) | 0.78540 rad. = 45° | Arccosine |
Math.asin(Math.SQRT1_2) | 0.78540 rad. = 45° | Arcsine |
Math.atan(1) | 0.78540 rad. = 45° | Half circle arctangent (-?/2 to +?/2) |
Math.atan2(-3.7, -3.7) | -2.3562 rad. = -135° | Whole circle arctangent (-? to +?) |
Math.ceil(1.1) | 2 | Ceiling: round up to smallest integer ? argument |
Math.cos(Math.PI/4) | 0.70711 | Cosine |
Math.exp(1) | 2.7183 | Exponential function: e raised to this power |
Math.floor(1.9) | 1 | Floor: round down to largest integer ? argument |
Math.log(Math.E) | 1 | Natural logarithm, base e |
Math.max(1, -2) | 1 | Maximum: (x > y) ? x : y |
Math.min(1, -2) | -2 | Minimum: (x < y) ? x : y |
Math.pow(-3, 2) | 9 | Exponentiation (raised to the power of): Math.pow(x, y) gives xy |
Math.random() | 0.17068 | Pseudorandom number between 0 (inclusive) and 1 (exclusive) |
Math.round(1.5) | 2 | Round to the nearest integer; half fractions are rounded up (e.g. 1.5 rounds to 2) |
Math.sin(Math.PI/4) | 0.70711 | Sine |
Math.sqrt(49) | 7 | Square root |
Math.tan(Math.PI/4) | 1 | Tangent |
Leider ist der Artikel nicht auf Deutsch verfügbar, jedoch sollte das meiste selbsterklärend sein.
Verwendet einfach mal ein paar dieser ausdrücke und testet was passiert :)
Vorherig
Object Initializer
Nächste
Date Objekte
Kostenlos
Javascript Tutorial
-
Einführung
-
Lektion1.1
-
Lektion1.2
-
Lektion1.3
-
Lektion1.4
-
-
Funktionen
-
Lektion2.1
-
Lektion2.2
-
Lektion2.3
-
Lektion2.4
-
Lektion2.5
-
Lektion2.6
-
-
Operatoren und Schleifen
-
Lektion3.1
-
Lektion3.2
-
Lektion3.3
-
Lektion3.4
-
Lektion3.5
-
Lektion3.6
-
-
If-Statements und Switch-Case
-
Lektion4.1
-
Lektion4.2
-
Lektion4.3
-
Lektion4.4
-
-
Objekte
-
Lektion5.1
-
Lektion5.2
-
Lektion5.3
-
Lektion5.4
-
Lektion5.5
-
Lektion5.6
-
-
Arrays
-
Lektion6.1
-
Lektion6.2
-
Lektion6.3
-
Lektion6.4
-
Lektion6.5
-
Lektion6.6
-
Beliebte Kurse
Spring Boot Webentwicklung - RESTful APIs entwickeln!
Lerne Spring Boot und erstelle RESTful APIs Das beliebteste Java...
29,99€
Die Java 11 Masterclass - Werde zum Profi-Entwickler!
Werde zum Entwickler mit der Java 11 Masterclass! Starte in...
29,99€
Spiele entwickeln mit Unity 3D – Erstelle eigene Games in C# - Starter
Willkommen zum kostenlosen Teil des Kurses: "Spiele entwickeln mit Unity...
Kostenlos