JavaScript Variables & Data Types Quiz
A focused JavaScript quiz dedicated to variables, scope, primitive values, reference types, and type conversion. Use this set to check how well you understand declarations, assignments, comparison rules, and everyday runtime behaviour.
Question 1
Which declaration keyword creates a variable whose binding cannot be reassigned?
Question 2
What is logged in the console?
console.log(typeof null)Question 3
What will this code output?
let count
console.log(count === undefined)Question 4
Which statement about primitive values is correct?
Question 5
What does this log?
const arr = [1, 2]
const copy = arr
copy.push(3)
console.log(arr.length)Question 6
Which value is NOT falsy in JavaScript?
Question 7
What will be printed?
const a = { value: 1 }
const b = { value: 1 }
console.log(a === b)Question 8
Which method converts the string "42" to the number 42 using unary syntax?
Question 9
How many primitive data types exist in JavaScript (ES2020)?
Question 10
What does this log?
let x = 5
x += "5"
console.log(x)Question 11
What is hoisting behaviour for variables declared with var?
Question 12
What will be logged?
console.log(typeof Symbol("id"))Question 13
Which statement correctly describes BigInt?
Question 14
What is output?
const score = "7"
console.log(score - 2)Question 15
How do you check if a value is NaN using the most robust approach?
Question 16
What is logged?
let name = "Ada"
function show() {
let name = "Grace"
console.log(name)
}
show()
console.log(name)Question 17
Which comparison returns true?
Question 18
What will `typeof []` return?
Question 19
Which statement best describes `let` declarations?
Question 20
What is logged?
const greeting = `Hello, ${"JS".toLowerCase()}!`
console.log(greeting)Question 21
Which operation converts a number to a string?
Question 22
What does this output?
const value = Boolean("0")
console.log(value)Question 23
Which operator checks reference equality for objects?
Question 24
What happens when you access an undeclared variable?
Question 25
What is the result?
const total = Number("5") + Number(true)
console.log(total)Question 26
Which method converts a value to a string in base 2?
Question 27
What does this log?
let value = 0
console.log(value ?? 10)Question 28
What is printed?
const scores = Object.freeze([1, 2, 3])
scores[0] = 99
console.log(scores[0])Question 29
Which expression returns true?
Question 30
How many arguments does the parseInt function accept?
Question 31
What does this log?
console.log(typeof (() => {}))Question 32
Which statement is true about const declarations?
Question 33
What is the result?
const message = "5" + 3
console.log(typeof message)Question 34
What will `typeof NaN` return?
Question 35
Which expression produces NaN?
Question 36
What does this log?
let value
console.log(typeof value)Question 37
Which statement about typeof is true?
Question 38
What is printed?
let count = 0
if (!count) {
count = 5
}
console.log(count)Question 39
Which option correctly uses optional chaining?
Question 40
What will this output?
const result = 1 / 0
console.log(result)Question 41
Which keyword is block scoped and subject to the temporal dead zone?
Question 42
What is the value of Boolean(undefined)?
Question 43
Which loose equality comparison evaluates to true?
Question 44
What is logged?
const value = +"hello"
console.log(value)Question 45
Which expression returns a symbol value?
Question 46
What will this log?
const nums = Object.seal([1, 2, 3])
nums.push(4)
console.log(nums.length)Question 47
Which statement is true about object references?
Question 48
What is the output?
const big = 10n
const num = 5
console.log(big + BigInt(num))Question 49
Which statement about JSON.stringify is correct?
Question 50
What will this log?
const settings = { theme: "dark" }
const copy = { ...settings }
copy.theme = "light"
console.log(settings.theme)