console.log(Boolean(0))
JavaScript Data Types and Conversions Quiz
Want to learn more than this quiz offers you? Have a look at my Frontend web
development courses.
Create an account and save your quiz results
Login and save your results
OR
Question 1/15
In JavaScript, which type of loop will run at least once no matter what?
Select your answer
Question 2/15
What does the `console.log(Boolean(0))` output in JavaScript?
console.log(Boolean(0))
Select your answer
Question 3/15
What will `"5" + 1` evaluate to in JavaScript?
"5" + 1
Select your answer
Question 4/15
Which statement will determine if the variable `x` is undefined?
let x;
Select your answer
Question 5/15
Which of the following is a primitive data type in JavaScript?
Select your answer
Question 6/15
If `let x;`, what is `x` initialized to?
let x;
Select your answer
Question 7/15
What does `parseInt("10.5")` return in JavaScript?
parseInt("10.5")
Select your answer
Question 8/15
What value is returned by the expression `Number(undefined)` in JavaScript?
Number(undefined)
Select your answer
Question 9/15
What is the value of `Boolean("false")` in JavaScript?
Boolean("false")
Select your answer
Question 10/15
What is `typeof NaN` in JavaScript?
typeof NaN
Select your answer
Question 11/15
Which of the following expressions will evaluate to `true`?
let a = 0;
let b = "0";
let c = false;
// expressions
a == b;
a === b;
b == c;
b === c;
Select your answer
Question 12/15
How do you correctly check if a variable is a string in JavaScript?
Select your answer
Question 13/15
Which JavaScript function would you use to combine variable `let a = 'Hello'; let b = 'World';` into a single output 'Hello World'?
let a = 'Hello';
let b = 'World';
Select your answer
Question 14/15
What result will `typeof undefined` produce?
typeof undefined
Select your answer
Question 15/15
What does the `===` operator compare?
Select your answer
Your Results
You did not answer any questions correctly.
Your Answers
Question 1/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
In JavaScript, which type of loop will run at least once no matter what?
Available answers
A `do...while` loop will execute the block of code at least once before checking the condition.
Question 2/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What does the `console.log(Boolean(0))` output in JavaScript?
Available answers
The number `0` is a falsy value, so `Boolean(0)` evaluates to `false`.
Question 3/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What will `"5" + 1` evaluate to in JavaScript?
"5" + 1
Available answers
In JavaScript, when using the + operator with a string and a number, the number is converted to a string, and string concatenation occurs. Thus, `"5" + 1` evaluates to `"51"`.
Question 4/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
Which statement will determine if the variable `x` is undefined?
let x;
Available answers
The `typeof` operator returns a string indicating the type of the unevaluated operand. To check if a variable is `undefined`, use `typeof x === 'undefined'` which safely checks even if `x` is undeclared.
Question 5/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
Which of the following is a primitive data type in JavaScript?
Available answers
Strings, numbers, booleans, null, and undefined are the primitive data types in JavaScript. `String` is one of them.
Question 6/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
If `let x;`, what is `x` initialized to?
let x;
Available answers
Variables declared using `let` without an initializer are initialized to `undefined`.
Question 7/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What does `parseInt("10.5")` return in JavaScript?
parseInt("10.5")
Available answers
The `parseInt` function converts a string to an integer. It parses up to the first invalid character for an integer, so `parseInt("10.5")` returns `10`.
Question 8/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What value is returned by the expression `Number(undefined)` in JavaScript?
Number(undefined)
Available answers
The `Number` function converts the value to a number. If it can't be converted to a number, it will return `NaN`. `undefined` is converted to `NaN`.
Question 9/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What is the value of `Boolean("false")` in JavaScript?
Boolean("false")
Available answers
When a string that is not empty (including the string "false") is converted to a boolean in JavaScript, it results in `true`. Non-empty strings are truthy values.
Question 10/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What is `typeof NaN` in JavaScript?
typeof NaN
Available answers
Despite being "Not-a-Number", `NaN` is of type `number` in JavaScript.
Question 11/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
Which of the following expressions will evaluate to `true`?
let a = 0;
let b = "0";
let c = false;
// expressions
a == b;
a === b;
b == c;
b === c;
Available answers
The `==` operator allows type coercion and `0`, `"0"`, and `false` are loosely equal in JavaScript, so `a == b` evaluates to `true`. However, `a === b`, which checks for both value and type equality, returns `false`.
Question 12/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
How do you correctly check if a variable is a string in JavaScript?
Available answers
Use `typeof variable === 'string'` to check if a variable is of type string properly.
Question 13/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
Which JavaScript function would you use to combine variable `let a = 'Hello'; let b = 'World';` into a single output 'Hello World'?
let a = 'Hello';
let b = 'World';
Available answers
In JavaScript, you use `a.concat(' ', b)` to combine two strings.
Question 14/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What result will `typeof undefined` produce?
typeof undefined
Available answers
In JavaScript, the `typeof` operator used on `undefined` returns `"undefined"`.
Question 15/15
😊 Your
answer was correct
🙁 Your
answer was incorrect
What does the `===` operator compare?
Available answers
The `===` operator in JavaScript checks for both value and type equality.