⊗jsPmObDAO 98 of 504 menu

Distinguishing arrays from objects in JavaScript

As mentioned above, the typeof operator does not distinguish between arrays and objects. Sometimes, however, this needs to be done. The function Array.isArray() will come to the rescue:

console.log( Array.isArray([]) ); // shows true console.log( Array.isArray({}) ); // shows false

Without running the code, determine what will be displayed on the console:

console.log( Array.isArray([1, 2, 3]) );

Without running the code, determine what will be displayed on the console:

console.log( Array.isArray({x: 1, y: 2, z: 3}) );
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline