aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/javascript/reference/operators/less_than/index.html
blob: 9833b8532e05f592b3a93a87ac932618beb39560 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
title: Менше ніж (<)
slug: Web/JavaScript/Reference/Operators/Less_than
tags:
  - JavaScript
  - Довідка
  - Оператор
translation_of: Web/JavaScript/Reference/Operators/Less_than
---
<div>{{jsSidebar("Operators")}}</div>

<p>Оператор менше ніж (<code>&lt;</code>) повертає <code>true</code>, якщо значення лівого операнда менше за значення правого операнда, інакше повертає <code>false</code>.</p>

<div>{{EmbedInteractiveExample("pages/js/expressions-less-than.html")}}</div>



<h2 id="Синтаксис">Синтаксис</h2>

<pre class="syntaxbox notranslate"> x &lt; y</pre>

<h2 id="Опис">Опис</h2>

<p>Операнди порівнюються за допомогою алгоритму <a class="external external-icon" href="https://tc39.es/ecma262/#sec-abstract-relational-comparison" rel="noopener">абстрактного порівняння</a>. Дивіться опис алгоритму у документації оператора <a href="/uk/docs/Web/JavaScript/Reference/Operators/Greater_than">більше ніж</a>.</p>

<h2 id="Приклади">Приклади</h2>

<h3 id="Порівняння_рядків">Порівняння рядків</h3>

<pre class="brush: js notranslate">console.log("а" &lt; "б");        // true
console.log("а" &lt; "а");        // false
console.log("а" &lt; "3");        // false</pre>

<h3 id="Порівняння_рядка_з_числом">Порівняння рядка з числом</h3>

<pre class="brush: js notranslate">console.log("5" &lt; 3);          // false
console.log("3" &lt; 3);          // false
console.log("3" &lt; 5);          // true

console.log("привіт" &lt; 5);      // false
console.log(5 &lt; "привіт");      // false

console.log("5" &lt; 3n);         // false
console.log("3" &lt; 5n);         // true</pre>

<h3 id="Порівняння_числа_з_числом">Порівняння числа з числом</h3>

<pre class="brush: js notranslate">console.log(5 &lt; 3);            // false
console.log(3 &lt; 3);            // false
console.log(3 &lt; 5);            // true</pre>

<h3 id="Порівняння_числа_з_BigInt">Порівняння числа з BigInt</h3>

<pre class="brush: js notranslate">console.log(5n &lt; 3);           // false
console.log(3 &lt; 5n);           // true</pre>

<h3 id="Порівняння_Boolean_null_undefined_NaN">Порівняння Boolean, null, undefined, NaN</h3>

<pre class="brush: js notranslate">console.log(true &lt; false);     // false
console.log(false &lt; true);     // true

console.log(0 &lt; true);         // true
console.log(true &lt; 1);         // false

console.log(null &lt; 0);         // false
console.log(null &lt; 1);         // true

console.log(undefined &lt; 3);    // false
console.log(3 &lt; undefined);    // false

console.log(3 &lt; NaN);          // false
console.log(NaN &lt; 3);          // false</pre>

<h2 id="Специфікації">Специфікації</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Специфікація</th>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-relational-operators', 'Relational operators')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>



<p>{{Compat("javascript.operators.less_than")}}</p>

<h2 id="Див._також">Див. також</h2>

<ul>
 <li><a href="/uk/docs/Web/JavaScript/Reference/Operators/Greater_than">Оператор більше ніж</a></li>
 <li><a href="/uk/docs/Web/JavaScript/Reference/Operators/Greater_than_or_equal">Оператор більше чи дорівнює</a></li>
 <li><a href="/uk/docs/Web/JavaScript/Reference/Operators/Less_than_or_equal">Оператор менше чи дорівнює</a></li>
</ul>