Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
Math.abs() は静的メソッドで、数値の絶対値を返します。
数値です。
x の絶対値です。x が負または -0 の場合は、その反対の数である -x (非負の値)を返します。それ以外の場合、x 自体を返します。したがって、返値は常に正の値または 0 となります。
abs() は Math オブジェクトの静的メソッドなので、 Math オブジェクトを生成してメソッドとして使用するのではなく、常に Math.abs() として使用するようにしてください (Math はコンストラクターではありません)。
Math.abs() は引数を数値に変換します。変換できない値は NaN となり、Math.abs() も NaN を返します。
| ECMAScript® 2027 Language Specification # sec-math.abs |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年12月27日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.