Праверка на масіў у JavaScript

Існуе спецыяльны метад Array.isArray, з дапамогай якога можна праверыць зменную на тое, ці змяшчае яна сапраўдны масіў ці не. Давайце праверым працу метаду.

Масіў:

javascriptlet test = [1, 2, 3];
let res  = Array.isArray(test);

console.log(res); // выведзе true

Аб'ект:

javascriptlet test = {a: 1, b: 2, c: 3};
let res  = Array.isArray(test);

console.log(res); // выведзе false

Прымітыў:

javascriptlet test = 'abcde';
let res  = Array.isArray(test);

console.log(res); // выведзе false

Псеўдамасіў:

javascriptlet test = document.querySelectorAll('p');
let res  = Array.isArray(test);

console.log(res); // выведзе false
Задание 1

Дадзены двухмерны масіў:

javascriptlet test = [
  [1, 2, 3],
  {a: 1, b: 2, c: 3},
  [3, 4, 5],
  {x: 1, y: 2, z: 3},
];

Перабярыце гэты масіў цыклам і для кожнага элемента праверце, масіў ён ці не.