CARVIEW |
Select Language
HTTP/2 200
content-type: text/html
x-guploader-uploadid: AAwnv3Ig_-cjpXE-sV4RwtWrm8XkHuA0Yy341JWAyp3D0-PUB2rzB66ke9u7-oEy7LlVI-mo
cache-control: public, max-age=3600
expires: Fri, 10 Oct 2025 06:39:31 GMT
last-modified: Fri, 10 Oct 2025 01:12:16 GMT
etag: W/"92bd0d8763f2bc1338f2c657d3ada7b9"
x-goog-generation: 1760058736375228
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 206615
x-goog-meta-goog-reserved-file-mtime: 1760057037
x-goog-hash: crc32c=8+J2wA==, md5=kr0Nh2PyvBM48sZX062nuQ==
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: 111a0ec038c012e313a560156e2ec852
date: Fri, 10 Oct 2025 05:39:32 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月.
小なりイコール演算子 (<=
) は、左オペランドが右オペランド以下の場合は true
を返し、それ以外の場合は false
を返します。
試してみましょう
console.log(5 <= 3);
// 予想される結果: false
console.log(3 <= 3);
// 予想される結果: true
// Compare bigint to number
console.log(3n <= 5);
// 予想される結果: true
console.log("aa" <= "ab");
// 予想される結果: true
構文
js
x <= y;
解説
オペランドは、小なり演算子と同じアルゴリズムを使用して、オペランドを入れ替えて比較され、結果が反転されます。 x <= y
は通常 !(y < x)
と同等ですが、 x <= y
と x > y
の両方が false
となる 2 つの例外があります。
- 一方のオペランドが長整数に変換される一方、もう一方が長整数値に変換できない(
BigInt()
に渡すと構文エラーを発生する)文字列に変換される場合。 - オペランドの一方が
NaN
に変換される場合。(例えば、数値に変換できない文字列やundefined
など。)
さらに、x <= y
は x
を y
より前にプリミティブ型に型変換し、y < x
は y
を x
より前にプリミティブ型に型変換します。型変換には副作用を 持つ可能性が あるため、オペランドの順序が重要になる場合があります。
x <= y
は、一般的に x > y || x == y
と同等ですが、次のいくつかの例外があります。
x
またはy
のいずれかがnull
で、もう一方がnull
ではなく、数値型への変換によって 0 になる値(0
、0n
、false
、""
、"0"
、new Date(0)
など)の場合、x <= y
はtrue
と評価され、x < y || x == y
はfalse
と評価されます。x
またはy
の一方がundefined
で、もう一方がnull
またはundefined
である場合、x <= y
はfalse
となる一方、x == y
はtrue
となります。x
とy
が同じオブジェクトであり、小なり演算の最初の段階の後でNaN
になる場合(new Date(NaN)
など)、x <= y
はfalse
となる一方、x == y
はtrue
となります。x
とy
が異なるオブジェクトであり、小なり演算の最初の段階の後、同じ値になる場合、x <= y
はtrue
となる一方、x < y || x == y
はfalse
となります。
例
>文字列と文字列の比較
js
"a" <= "b"; // true
"a" <= "a"; // true
"a" <= "3"; // false
文字列と数値の比較
js
"5" <= 3; // false
"3" <= 3; // true
"3" <= 5; // true
"hello" <= 5; // false
5 <= "hello"; // false
数値と数値の比較
js
5 <= 3; // false
3 <= 3; // true
3 <= 5; // true
数値と長整数の比較
js
5n <= 3; // false
3 <= 3n; // true
3 <= 5n; // true
論理値、null、undefined、NaN の比較
js
true <= false; // false
true <= true; // true
false <= true; // true
true <= 0; // false
true <= 1; // true
null <= 0; // true
1 <= null; // false
undefined <= 3; // false
3 <= undefined; // false
3 <= NaN; // false
NaN <= 3; // false
仕様書
Specification |
---|
ECMAScript® 2026 Language Specification> # sec-relational-operators> |
ブラウザーの互換性
Loading…