JavaScript Data Types and Conversions Quiz

Create an account and save your quiz results

Login and save your results

OR

Question 1/15

Which statement will create an object from an empty object in JavaScript?
let obj = {};

Select your answer

Question 2/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 3/15

What does `parseFloat("12.34abc")` return in JavaScript?
parseFloat("12.34abc")

Select your answer

Question 4/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 5/15

What is the value of `Boolean("false")` in JavaScript?
Boolean("false")

Select your answer

Question 6/15

How do you correctly check if a variable is a string in JavaScript?

Select your answer

Question 7/15

Which JavaScript type has no methods or properties of its own?

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

Which statement will determine if the variable `x` is undefined?
let x;

Select your answer

Question 10/15

What does the `===` operator compare?

Select your answer

Question 11/15

How can you check if a number is not a number using a built-in JavaScript function?

Select your answer

Question 12/15

What is the result of `"5" - 1` in JavaScript?
"5" - 1

Select your answer

Question 13/15

Which of the following is a primitive data type in JavaScript?

Select your answer

Question 14/15

Which of the following is NOT a falsy value in JavaScript?

Select your answer

Question 15/15

Which value is obtained from the expression `"5" * "2"`?
"5" * "2"

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
Which statement will create an object from an empty object in JavaScript?
let obj = {};

Available answers

`Object.assign` can be used to copy all enumerable properties from one (or more) source objects to a target object. `Object.assign(obj)` will just return `obj` if it doesn't have another source object.
Question 2/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 3/15
😊 Your answer was correct 🙁 Your answer was incorrect
What does `parseFloat("12.34abc")` return in JavaScript?
parseFloat("12.34abc")

Available answers

The `parseFloat` function converts a string to a floating-point number up to the first invalid character. Thus, `parseFloat("12.34abc")` returns `12.34`.
Question 4/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 5/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 6/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 7/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which JavaScript type has no methods or properties of its own?

Available answers

`Undefined` is a primitive data type in JavaScript, which has no properties or methods.
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
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 10/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.
Question 11/15
😊 Your answer was correct 🙁 Your answer was incorrect
How can you check if a number is not a number using a built-in JavaScript function?

Available answers

The `isNaN` function checks whether a value is `NaN`. If the result of the expression is `NaN`, `isNaN` returns `true`.
Question 12/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the result of `"5" - 1` in JavaScript?
"5" - 1

Available answers

In JavaScript, the `-` operator converts operands to numbers if they're not, so `"5" - 1` evaluates to `4`.
Question 13/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 14/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which of the following is NOT a falsy value in JavaScript?

Available answers

In JavaScript, the string "false" is not falsy. Falsy values include `false`, `0`, `NaN`, `""` (empty string), `null`, and `undefined`.
Question 15/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which value is obtained from the expression `"5" * "2"`?
"5" * "2"

Available answers

The `*` operator converts both strings to numbers in this case, so `"5" * "2"` equals `10`.