大なり演算子 (>) は、左辺のオペランドが右辺のオペランドより大きい場合は true を返し、それ以外の場合は false を返します。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
構文
x > y
解説
オペランドは、 抽象関係比較 アルゴリズムを使用して比較されます。このアルゴリズムの概要については、 小なり 演算子のドキュメントを参照して下さい。
例
文字列と文字列の比較
console.log("a" > "b"); // false
console.log("a" > "a"); // false
console.log("a" > "3"); // true
文字列と数値の比較
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
数値と数値の比較
console.log(5 > 3); // true console.log(3 > 3); // false console.log(3 > 5); // false
数値と BigInt の比較
console.log(5n > 3); // true console.log(3 > 5n); // false
ブール値、 null 、 undefined 、 NaN の比較
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
仕様
| 仕様 |
|---|
| ECMAScript (ECMA-262) Relational operators の定義 |
ブラウザーの互換性
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.
Update compatibility data on GitHub
| デスクトップ | モバイル | サーバー | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Greater than (a > b) | Chrome 完全対応 1 | Edge 完全対応 12 | Firefox 完全対応 1 | IE 完全対応 3 | Opera 完全対応 3 | Safari 完全対応 1 | WebView Android 完全対応 1 | Chrome Android 完全対応 18 | Firefox Android 完全対応 4 | Opera Android 完全対応 10.1 | Safari iOS 完全対応 1 | Samsung Internet Android 完全対応 1.0 | nodejs 完全対応 0.1.100 |
凡例
- 完全対応
- 完全対応