Die Math.cos()
Funktion gibt den Cosinus eines Winkels zurück. Der Winkel muss im Bogenmaß angegeben werden. Der Wert ist .
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
Math.cos(x)
Parameter
x
- Eine Zahl im Winkelmaß (rad).
Rückgabewert
Der Cosinus der übergebenen Zahl.
Beschreibung
Die Math.cos()
Funktion gibt einen nummerischen Wert zwischen -1 und 1 zurück. Dieser repräsentiert den Cosinus des Winkels.
Weil cos()
eine statische Funktion von Math
ist, wird es immer als Math.cos()
eingesetzt,
jedoch nicht als Methode eines erzeugten Math
Objektes (Math
ist kein Konstruktor).
Beispiele
Einsatz von Math.cos()
Math.cos(0); // 1
Math.cos(1); // 0.5403023058681398
Math.cos(Math.PI); // -1
Math.cos(2 * Math.PI); // 1
Spezifikationen
Spezifikationen | Status | Kommentar |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initiale Definition. Implementiert in JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) Die Definition von 'Math.cos' in dieser Spezifikation. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Math.cos' in dieser Spezifikation. |
Standard | |
ECMAScript (ECMA-262) Die Definition von 'Math.cos' in dieser Spezifikation. |
Lebender Standard |
Browserkompatibilität
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.