Recall & Review
beginner
What does the
typeof operator do in JavaScript?It tells you the type of a value or variable, like whether it is a number, string, boolean, object, function, or undefined.
Click to reveal answer
beginner
What is the result of
typeof 42?The result is
"number" because 42 is a number.Click to reveal answer
intermediate
What does
typeof null return and why is it special?It returns
"object". This is a known quirk in JavaScript where null is considered an object type even though it means 'no value'.Click to reveal answer
beginner
How can you check if a variable is a function using
typeof?Use
typeof variable === 'function'. This returns true if the variable holds a function.Click to reveal answer
intermediate
What type does
typeof return for arrays?It returns
"object" because arrays are a special kind of object in JavaScript.Click to reveal answer
What will
typeof 'hello' return?✗ Incorrect
typeof returns "string" for text values.Which
typeof result means the variable is not defined or has no value?✗ Incorrect
"undefined" means a variable has no assigned value.
What does
typeof function() {} return?✗ Incorrect
Functions return "function" when checked with
typeof.What is the
typeof result for an array like []?✗ Incorrect
Arrays are objects in JavaScript, so
typeof returns "object".Why is
typeof null considered a quirk?✗ Incorrect
typeof null returns "object" even though null means no value.Explain how the
typeof operator helps in checking variable types in JavaScript.Think about how you can tell what kind of value a variable holds.
You got /3 concepts.
Describe the special case of
typeof null and why it might confuse beginners.Consider what null means and what typeof returns.
You got /3 concepts.