0
0
Javascriptprogramming~20 mins

Type checking using typeof in Javascript - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Type Checking Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of typeof with different values
What is the output of the following code snippet?
Javascript
console.log(typeof null);
A"boolean"
B"object"
C"undefined"
D"null"
Attempts:
2 left
💡 Hint
Remember that typeof null is a known quirk in JavaScript.
Predict Output
intermediate
2:00remaining
Type of an array using typeof
What will be the output of this code?
Javascript
console.log(typeof [1, 2, 3]);
A"object"
B"array"
C"list"
D"undefined"
Attempts:
2 left
💡 Hint
Arrays are a special kind of object in JavaScript.
Predict Output
advanced
2:00remaining
Output of typeof with function and symbol
What is the output of this code snippet?
Javascript
console.log(typeof function() {});
console.log(typeof Symbol('id'));
A"function" and "symbol"
B"object" and "string"
C"function" and "object"
D"object" and "symbol"
Attempts:
2 left
💡 Hint
Functions have their own type, and symbols are a unique primitive type.
Predict Output
advanced
2:00remaining
Type of NaN using typeof
What will this code output?
Javascript
console.log(typeof NaN);
A"undefined"
B"NaN"
C"number"
D"object"
Attempts:
2 left
💡 Hint
NaN stands for Not-a-Number but is still a number type in JavaScript.
Predict Output
expert
2:00remaining
Type checking with typeof and undefined variables
What is the output of this code?
Javascript
let a;
console.log(typeof a);
console.log(typeof b);
AReferenceError and ReferenceError
BReferenceError and "undefined"
C"undefined" and ReferenceError
D"undefined" and "undefined"
Attempts:
2 left
💡 Hint
typeof returns "undefined" for both declared but unassigned variables and undeclared variables without throwing errors.