This content originally appeared on DEV Community and was authored by Coderslang: Become a Software Engineer
Array? Object? Undefined? What’s the output?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
In JavaScript, the +
operator doesn’t do the concatenation of arrays.
Instead, it transforms them into strings and then does the string concatenation.
Two empty arrays become two empty strings, and their sum unsurprisingly is still an empty string.
What matters to us is the typeof
that will return string
in our case.
ANSWER: the output will be string
.
This content originally appeared on DEV Community and was authored by Coderslang: Become a Software Engineer
Coderslang: Become a Software Engineer | Sciencx (2021-04-16T12:09:00+00:00) JavaScript Interview Question #33: Add two empty arrays and check the type. Retrieved from https://www.scien.cx/2021/04/16/javascript-interview-question-33-add-two-empty-arrays-and-check-the-type/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.