JS Test #7: Is this an array?

coderslang

Coderslang: Become a Software Engineer

Posted on February 7, 2021

JS Test #7: Is this an array?

Is array an array?

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

At line one we create an array and bind it with the array constant. Then the type of the value of this constant is evaluated by the typeof operator.

There’s no such type as array in JS, so it’s impossible to see the message ARRAY! on the screen. In fact, all JS arrays are objects, so the execution goes into the else branch, and SOMETHING WEIRD is printed on the screen.


ANSWER: SOMETHING WEIRD will be logged to the screen as all JS arrays have the type object.

💖 💪 🙅 🚩
coderslang
Coderslang: Become a Software Engineer

Posted on February 7, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

The Beginning Stage of Learning JavaScript
beginners The Beginning Stage of Learning JavaScript

February 21, 2022

JS Test #7: Is this an array?
beginners JS Test #7: Is this an array?

February 7, 2021

JS Test #4: try/catch
beginners JS Test #4: try/catch

February 4, 2021