Math.cos()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Math.cos()
정적 메서드는 숫자의 코사인을 라디안 단위로 반환합니다.
시도해보기
function getCircleX(radians, radius) {
return Math.cos(radians) * radius;
}
console.log(getCircleX(1, 10));
// Expected output: 5.403023058681398
console.log(getCircleX(2, 10));
// Expected output: -4.161468365471424
console.log(getCircleX(Math.PI, 10));
// Expected output: -10
구문
js
Math.cos(x)
매개변수
x
-
라디안 단위로 각도를 나타내는 숫자입니다.
반환 값
설명
cos()
는 Math
의 정적 메서드이므로, 생성한 Math
객체의 메서드가 아닌 Math.cos()
로 항상 사용합니다(Math
는 생성자가 아닙니다).
예제
Math.cos() 사용하기
js
Math.cos(-Infinity); // NaN
Math.cos(-0); // 1
Math.cos(0); // 1
Math.cos(1); // 0.5403023058681398
Math.cos(Math.PI); // -1
Math.cos(2 * Math.PI); // 1
Math.cos(Infinity); // NaN
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-math.cos |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cos |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on 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.