Primitive data types are the most basic data types in JavaScript. They represent simple values and are not objects. Examples include string, number, boolean, null, undefined, symbol, and bigint.
Click to reveal answer
beginner
What is the difference between null and undefined?
null means a variable has been explicitly set to have no value. undefined means a variable has been declared but not assigned any value yet.
Click to reveal answer
beginner
Which primitive data type is used to represent true or false values?
The boolean data type represents logical values: true or false.
Click to reveal answer
intermediate
What is a symbol in JavaScript?
A symbol is a unique and immutable primitive value often used to create unique object property keys to avoid name conflicts.
Click to reveal answer
intermediate
How do you create a BigInt value in JavaScript?
You create a BigInt by appending n to the end of an integer literal, for example: 123n. BigInt is used for integers larger than the Number type can safely represent.
Click to reveal answer
Which of the following is NOT a primitive data type in JavaScript?
ABoolean
BString
CObject
DSymbol
✗ Incorrect
Objects are not primitive data types; they are complex data types that can hold multiple values.
What value does an uninitialized variable hold in JavaScript?
Aundefined
Bfalse
C0
Dnull
✗ Incorrect
An uninitialized variable holds the value undefined.
Which primitive type would you use to store the text 'Hello'?
AString
BNumber
CBoolean
DSymbol
✗ Incorrect
Text values are stored as String primitive type.
How do you create a BigInt literal?
ABy calling BigInt() without arguments
BBy writing a number with a decimal point
CBy using quotes around a number
DBy appending 'n' to an integer
✗ Incorrect
Appending 'n' to an integer creates a BigInt literal, e.g., 9007199254740991n.
Which primitive type is used to represent a unique identifier?
ABoolean
BSymbol
CNull
DUndefined
✗ Incorrect
Symbol is used to create unique identifiers.
Explain the main primitive data types in JavaScript and give a simple example of each.
Think about the simplest values you can store in variables.
You got /8 concepts.
Describe the difference between null and undefined in JavaScript.
Consider what happens when you declare a variable but don’t assign it.
You got /3 concepts.
Practice
(1/5)
1. Which of the following is NOT a primitive data type in JavaScript?
easy
A. object
B. boolean
C. string
D. number
Solution
Step 1: Recall JavaScript primitive types
JavaScript primitive types include string, number, boolean, undefined, null, symbol, and bigint.
Step 2: Identify non-primitive types
Object is not a primitive type; it is a complex data type used to store collections.
Final Answer:
object -> Option A
Quick Check:
Primitive types exclude objects [OK]
Hint: Remember: objects are NOT primitives, others are [OK]
Common Mistakes:
Confusing object with primitive types
Thinking null is an object
Mixing symbol with object
2. Which of the following is the correct way to declare a variable with a string primitive in JavaScript?
easy
A. let name = John;
B. let name = 'John';
C. let name = "John;
D. let name = `John;
Solution
Step 1: Check string declaration syntax
Strings must be enclosed in matching quotes: single ('') or double ("") or backticks (``).
Step 2: Validate each option
let name = 'John'; uses single quotes correctly. let name = John; lacks quotes. Options C and D have unclosed quotes.
Final Answer:
let name = 'John'; -> Option B
Quick Check:
Strings need matching quotes [OK]
Hint: Strings always need matching quotes around text [OK]