1 added
3 removed
Original
2026-01-01
Modified
2026-02-26
1
<h2>Ответы</h2>
1
<h2>Ответы</h2>
2
<p>Для того, чтобы проверить является ли переменная массивом, можно воспользоваться встроенным методом Array.isArray().</p>
2
<p>Для того, чтобы проверить является ли переменная массивом, можно воспользоваться встроенным методом Array.isArray().</p>
3
-
<p>0</p>
4
<p>Предлагаю воспользоваться оператором<strong>instanceof</strong>:</p>
3
<p>Предлагаю воспользоваться оператором<strong>instanceof</strong>:</p>
5
<h4>Документация:</h4>
4
<h4>Документация:</h4>
6
<ul><li><a>instanceof</a></li>
5
<ul><li><a>instanceof</a></li>
7
-
</ul><p>0</p>
6
+
</ul><p>Предлагаю на рассмотрение такой метод:</p>
8
-
<p>Предлагаю на рассмотрение такой метод:</p>
9
<p>const arr = [1,2,3,4,5]; const arrEmpty = []; const text = 'Text here'; const object = { name: 'Max', age: 30 }; const number = 5; console.log(typeof arr === 'object' && arr !== null && arr.length >= 0) // => true console.log(typeof arrEmpty === 'object' && arrEmpty !== null && arrEmpty.length >= 0) // => true console.log(typeof text === 'object' && text !== null && text.length >= 0) // => false console.log(typeof object === 'object' && object !== null && object.length >= 0) // => false console.log(typeof number === 'object' && number !== null && number.length >= 0) // => false</p>
7
<p>const arr = [1,2,3,4,5]; const arrEmpty = []; const text = 'Text here'; const object = { name: 'Max', age: 30 }; const number = 5; console.log(typeof arr === 'object' && arr !== null && arr.length >= 0) // => true console.log(typeof arrEmpty === 'object' && arrEmpty !== null && arrEmpty.length >= 0) // => true console.log(typeof text === 'object' && text !== null && text.length >= 0) // => false console.log(typeof object === 'object' && object !== null && object.length >= 0) // => false console.log(typeof number === 'object' && number !== null && number.length >= 0) // => false</p>