CARVIEW |
Select Language
HTTP/2 200
content-type: text/html
x-guploader-uploadid: AAwnv3JLYhibZ_6k4FcUlBC1SuV7D7vpAbg-s5yg5mgjYdtNAgIvZakn9W3gpA2w5Y9DDoR7
cache-control: public, max-age=3600
expires: Sun, 12 Oct 2025 20:46:14 GMT
last-modified: Fri, 10 Oct 2025 01:12:16 GMT
etag: W/"9dfad51c9c88f17c36a0fbbd73fbe38c"
x-goog-generation: 1760058736092321
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 205892
x-goog-meta-goog-reserved-file-mtime: 1760057037
x-goog-hash: crc32c=nWzIcg==, md5=nfrVHJyI8Xw2oPu9c/vjjA==
x-goog-storage-class: STANDARD
accept-ranges: none
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
alt-svc: clear
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
strict-transport-security: max-age=63072000
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net mdn.github.io live-samples.mdn.mozilla.net live-samples.mdn.allizom.net *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-frame-options: DENY
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
x-cloud-trace-context: ba1987c6036b2ee8180b7789eb596784
date: Sun, 12 Oct 2025 19:46:14 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache: miss
除算演算子 (/) - JavaScript | MDN
Toggle sidebar
>
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
除算演算子 (/)
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
除算演算子 (/
) は、左のオペランドを被除数とし、右のオペランドを除数としたオペランド同士の除算結果を生成します。
試してみましょう
console.log(12 / 2);
// 予想される結果: 6
console.log(3 / 2);
// 予想される結果: 1.5
console.log(6 / "3");
// 予想される結果: 2
console.log(2 / 0);
// 予想される結果: Infinity
構文
js
x / y
解説
/
演算子は、数値と長整数の 2 種類のオペランドに対してオーバーロードされています。まず両オペランドを数値型に変換し、それらの型を検査します。両オペランドが長整数になった場合、長整数の除算を実行します。そうでない場合は数値除算を実行します。一方のオペランドが長整数になり、もう一方が数値になった場合は、TypeError
が発生します。
長整数の除算では、結果は両オペランドの商を0方向に切り捨てた値となり、余りは破棄されます。除数 y
が 0n
の場合、RangeError
が発生します。これは数値除算で 0 を割ると Infinity
または -Infinity
を返すのに対し、長整数には無限大の概念が存在しないためです。
例
>基本的な除算
js
1 / 2; // 0.5
Math.floor(3 / 2); // 1
1.0 / 2.0; // 0.5
2 / 0; // Infinity
2.0 / 0.0; // Infinity, because 0.0 === 0
2.0 / -0.0; // -Infinity
長整数以外の値は数値に変換されます。
js
5 / "2"; // 2.5
5 / "foo"; // NaN
長整数を使用した除算
js
1n / 2n; // 0n
5n / 3n; // 1n
-1n / 3n; // 0n
1n / -3n; // 0n
2n / 0n; // RangeError: BigInt division by zero
除算で長整数と数値オペランドが混在させることはできません。
js
2n / 2; // TypeError: Cannot mix BigInt and other types, use explicit conversions
2 / 2n; // TypeError: Cannot mix BigInt and other types, use explicit conversions
長整数と長整数以外による除算を行うには、どちらかのオペランドを変換してください。
js
2n / BigInt(2); // 1n
Number(2n) / 2; // 1
仕様書
Specification |
---|
ECMAScript® 2026 Language Specification> # sec-multiplicative-operators> |
ブラウザーの互換性
Loading…