大なり (>)
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.
大なり演算子 (>
) は、左辺のオペランドが右辺のオペランドより大きい場合は true
を返し、それ以外の場合は false
を返します。
試してみましょう
console.log(5 > 3);
// Expected output: true
console.log(3 > 3);
// Expected output: false
// Compare bigint to number
console.log(3n > 5);
// Expected output: false
console.log("ab" > "aa");
// Expected output: true
構文
js
x > y;
解説
例
文字列と文字列の比較
js
console.log("a" > "b"); // false
console.log("a" > "a"); // false
console.log("a" > "3"); // true
文字列と数値の比較
js
console.log("5" > 3); // true
console.log("3" > 3); // false
console.log("3" > 5); // false
console.log("hello" > 5); // false
console.log(5 > "hello"); // false
console.log("5" > 3n); // true
console.log("3" > 5n); // false
数値と数値の比較
js
console.log(5 > 3); // true
console.log(3 > 3); // false
console.log(3 > 5); // false
Number と BigInt の比較
js
console.log(5n > 3); // true
console.log(3 > 5n); // false
論理値、null、undefined、NaN の比較
js
console.log(true > false); // true
console.log(false > true); // false
console.log(true > 0); // true
console.log(true > 1); // false
console.log(null > 0); // false
console.log(1 > null); // true
console.log(undefined > 3); // false
console.log(3 > undefined); // false
console.log(3 > NaN); // false
console.log(NaN > 3); // false
仕様書
Specification |
---|
ECMAScript® 2025 Language Specification # sec-relational-operators |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Greater than ( a > b ) |
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.