Variables & Data Types
Difficulty: easy
Overview
JavaScript has three variable declarations: var (function-scoped, hoisted), let (block-scoped, not hoisted into usable state), and const (block-scoped, must be initialised). Primitive types are string, number, bigint, boolean, undefined, null, and symbol. Objects (including arrays and functions) are reference types. Use typeof to inspect a value's type at runtime.
Practice Linked Questions
Q1. Which keyword declares a block-scoped variable that cannot be reassigned?
Select one answer before revealing.
Q2. What does `typeof null` return in JavaScript?
Select one answer before revealing.
Q3. Which of the following are primitive data types in JavaScript? (More than one answer may be correct.)
Select one answer before revealing.
Q4. What does `console.log(typeof undefined)` output?
Select one answer before revealing.
Q5. What is the output? ```js let a = 10; let b = a; b = 20; console.log(a); ```
Select one answer before revealing.
Q6. What is the output? ```js let x; console.log(x); ```
Select one answer before revealing.