小なりイコール演算子 (<=
) は、左のオペランドが右のオペランドより小さいか等しい場合に true
を返し、それ以外の場合は false
を返します。
このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 https://github.com/mdn/interactive-examples をクローンしてプルリクエストを送信してください。
構文
x <= y
解説
例
文字列と文字列の比較
console.log("a" <= "b"); // true
console.log("a" <= "a"); // true
console.log("a" <= "3"); // false
文字列と数値の比較
console.log("5" <= 3); // false
console.log("3" <= 3); // true
console.log("3" <= 5); // true
console.log("hello" <= 5); // false
console.log(5 <= "hello"); // false
数値と数値の比較
console.log(5 <= 3); // false
console.log(3 <= 3); // true
console.log(3 <= 5); // true
数値と BigInt の比較
console.log(5n <= 3); // false
console.log(3 <= 3n); // true
console.log(3 <= 5n); // true
論理型, null, undefined, NaN の比較
console.log(true <= false); // false
console.log(true <= true); // true
console.log(false <= true); // true
console.log(true <= 0); // false
console.log(true <= 1); // true
console.log(null <= 0); // true
console.log(1 <= null); // false
console.log(undefined <= 3); // false
console.log(3 <= undefined); // false
console.log(3 <= NaN); // false
console.log(NaN <= 3); // false
仕様書
ブラウザーの互換性
BCD tables only load in the browser
このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 https://github.com/mdn/browser-compat-data をチェックアウトしてプルリクエストを送信してください。