Question 5
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log(typeof null, typeof function () {}, typeof []);
- A object function object Correct
- B null function array
- C object object object
- D null object array
Correct Answer: Option A
typeof null is "object" (a historic bug), functions report "function", and arrays are objects. Use Array.isArray() to detect arrays.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!