-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
JS Basics
JS Variables & Operators
JS Data Types & Conversion
JS Numbers & Math
JS Strings
JS Dates
JS Arrays
JS Control Flow
JS Loops & Iteration
JS Functions
JS Functions
Function Definitions
Function Parameters
Function Invocation
Function Call
Function Apply
Function Bind
Function Closures
JS Arrow Function
JS Objects
JS Objects
JS Object Properties
JS Object Methods
JS Object Display
JS Object Constructors
Object Definitions
Object Get / Set
Object Prototypes
Object Protection
JS Classes & Modules
JS Async Programming
JS Advanced
JS Destructuring
JS Bitwise
JS RegExp
JS Precedence
JS Errors
JS Scope
JS Hoisting
JS Strict Mode
JS this Keyword
JS HTML DOM
DOM Intro
DOM Methods
DOM Document
DOM Elements
DOM HTML
DOM Forms
DOM CSS
DOM Animations
DOM Events
DOM Event Listener
DOM Navigation
DOM Nodes
DOM Collections
DOM Node Lists
JS BOM (Browser Object Model)
JS Window
JS Screen
JS Location
JS History
JS Navigator
JS Popup Alert
JS Timing
JS Cookies
Web Storage API
JS Web APIs
JS AJAX
AJAX Intro
AJAX XMLHttp
AJAX Request
AJAX Response
AJAX XML File
AJAX PHP
AJAX ASP
AJAX Database
AJAX Applications
AJAX Examples
JS JSON
JSON Intro
JSON Syntax
JSON vs XML
JSON Data Types
JSON Parse
JSON Stringify
JSON Objects
JSON Arrays
JSON Server
JSON PHP
JSON HTML
JSON JSONP
JS Canvas
JS Graphics & Charts
JS Basics
JS Variables & Operators
JS Data Types & Conversion
JS Numbers & Math
JS Strings
JS Dates
JS Arrays
JS Control Flow
JS Loops & Iteration
JS Functions
JS Functions
Function Definitions
Function Parameters
Function Invocation
Function Call
Function Apply
Function Bind
Function Closures
JS Arrow Function
JS Objects
JS Objects
JS Object Properties
JS Object Methods
JS Object Display
JS Object Constructors
Object Definitions
Object Get / Set
Object Prototypes
Object Protection
JS Classes & Modules
JS Async Programming
JS Advanced
JS Destructuring
JS Bitwise
JS RegExp
JS Precedence
JS Errors
JS Scope
JS Hoisting
JS Strict Mode
JS this Keyword
JS HTML DOM
DOM Intro
DOM Methods
DOM Document
DOM Elements
DOM HTML
DOM Forms
DOM CSS
DOM Animations
DOM Events
DOM Event Listener
DOM Navigation
DOM Nodes
DOM Collections
DOM Node Lists
JS BOM (Browser Object Model)
JS Window
JS Screen
JS Location
JS History
JS Navigator
JS Popup Alert
JS Timing
JS Cookies
Web Storage API
JS Web APIs
JS AJAX
AJAX Intro
AJAX XMLHttp
AJAX Request
AJAX Response
AJAX XML File
AJAX PHP
AJAX ASP
AJAX Database
AJAX Applications
AJAX Examples
JS JSON
JSON Intro
JSON Syntax
JSON vs XML
JSON Data Types
JSON Parse
JSON Stringify
JSON Objects
JSON Arrays
JSON Server
JSON PHP
JSON HTML
JSON JSONP
JS Canvas
JS Graphics & Charts
In JavaScript, data types define the type of data a variable can hold. JavaScript is dynamically typed, meaning variables can hold any type of value at any time.
These are immutable and hold single values.
Data Type | Example |
---|---|
String | "Hello" , 'World' |
Number | 42 , 3.14 |
Boolean | true , false |
Null | null |
Undefined | undefined |
BigInt | 12345678901234567890n |
Symbol | Symbol("id") |
These hold collections of values or complex entities.
Data Type | Example |
---|---|
Object | {name: "Alice", age: 25} |
Array | ["apple", "banana", "cherry"] |
Function | function greet() {} |
Date | new Date() |
You can check the data type of a value using typeof
:
typeof "Hello" // "string"
typeof 123 // "number"
typeof true // "boolean"
typeof undefined // "undefined"
typeof null // "object" ✅ (known JS quirk)
typeof [1, 2, 3] // "object"
typeof {a: 1} // "object"
typeof function(){}// "function"
null
is of type object (this is a bug in JavaScript)
Arrays and functions are technically objects
Data types can change dynamically during execution
Q1. How do you declare a string variable named greeting
with the value "Hello World"
?
Q2. How do you declare a number variable price
with the value 199.99
?
Q3. How do you check if a variable isActive
is a boolean using the typeof
operator?
Q4. How do you define an array fruits
containing "apple"
, "banana"
, and "mango"
?
Q5. How do you create an object person
with properties name: "John"
and age: 30
?
Q6. How do you define a variable discount
with the value null
and check its type using typeof
?
Q7. How do you define a function greet()
that prints "Hi"
and check its type?
Q8. How do you assign a BigInt value 12345678901234567890n
to a variable bigNum
?
Q9. How do you declare an undefined
variable named result
?
Q10. How do you create a variable now
and assign the current date and time using Date()
object?
Q1: Which of the following is a primitive data type in JavaScript?
Q2: What is the result of typeof null?
Q3: Which keyword is used to declare a variable without assigning a value?
Q4: Which operator is used to check the data type of a variable?
Q5: What will typeof [1,2,3] return?
Q6: Which of the following is NOT a primitive data type?
Q7: What is the output of typeof function(){}?
Q8: Which of these values is of type Boolean?
Q9: Which of the following is the correct way to define a BigInt?
Q10: Which statement is true about JavaScript data types?