Navigate
JavaScript Tutorial for Beginners
The Ultimate CSS Tutorial for Beginners
Data Structure Tutorial for Beginners
ReactJS Tutorial for Beginners
Java Tutorial for Beginners
Node.js Tutorial for Beginners
SQL Tutorial for Beginners
Variables and Data Types in JavaScript
Content
- Variables
- Data Types
- Example
- Activity
- Quiz
- Updated on 10/09/2024
- 450 Views
Variables
Used to store data values. Declared using var, let, or const.
Data Types
Primitive Types: Number, String, Boolean, Undefined, Null, Symbol. Complex Types: Object, Array.
Example
image
Activity
Write a JavaScript program that declares variables of different types and prints them to the console.
Quiz
1. Which keyword is used to declare a variable that can be reassigned?
- a) var
- b) let
- c) const
- d) All of the above
2. True or False: null and undefined are the same in JavaScript
- a) True
- b) False
3. What data type is 42?
- a) String
- b) Number
- c) Boolean
- d) Object
4. Which of the following is a primitive type in JavaScript?
- a) Object
- b) Array
- c) Symbol
- d) Function
5. True or False: Variables declared with const can be reassigned.
- a) True
- b) False
Unlock Expert Career Advice For Free
