-
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
Operators are used to perform operations on variables and values. JavaScript includes many types of operators for different tasks like math, logic, assignment, and comparison.
Used to perform mathematical operations:
Operator | Description | Example |
---|---|---|
+ |
Addition | x + y |
- |
Subtraction | x - y |
* |
Multiplication | x * y |
/ |
Division | x / y |
% |
Modulus (remainder) | x % y |
** |
Exponentiation | x ** y |
++ |
Increment | x++ or ++x |
-- |
Decrement | x-- or --x |
Used to assign values to variables:
Operator | Example | Same As |
---|---|---|
= |
x = y |
x = y |
+= |
x += y |
x = x + y |
-= |
x -= y |
x = x - y |
*= |
x *= y |
x = x * y |
/= |
x /= y |
x = x / y |
%= |
x %= y |
x = x % y |
Used to compare values and return true
or false
:
Operator | Description | Example |
---|---|---|
== |
Equal to | x == y |
=== |
Equal value and type | x === y |
!= |
Not equal | x != y |
!== |
Not equal value or type | x !== y |
> |
Greater than | x > y |
< |
Less than | x < y |
>= |
Greater than or equal to | x >= y |
<= |
Less than or equal to | x <= y |
Used to combine conditions:
Operator | Description |
---|---|
&& |
Logical AND (both true) |
` | |
! |
Logical NOT (inverse) |
Operator | Description |
---|---|
typeof |
Returns the type |
instanceof |
Checks if an object is an instance of a class |
The +
operator can also join strings:
let firstName = "John";
let lastName = "Doe";
let fullName = firstName + " " + lastName; // "John Doe"
Q1. How do you add two numbers a = 5
and b = 10
and store the result in sum
using an arithmetic operator?
Q2. How do you increment a variable x
by 1 using the ++
operator?
Q3. How do you use the +=
assignment operator to add 20 to a variable points
?
Q4. How do you compare two variables x = 5
and y = "5"
using the ==
operator and the ===
operator?
Q5. How do you check if a number age
is greater than or equal to 18 using a comparison operator?
Q6. How do you write a condition using logical AND (&&
) to check if age
is greater than 18 and citizen
is true?
Q7. How do you use the modulus operator to check if a number x
is even?
Q8. How do you use the typeof
operator to find the type of a variable name
?
Q9. How do you concatenate two strings "Hello"
and "World"
using the +
operator and store in message
?
Q10. How do you use instanceof
to check if a variable person
is an instance of a class Person
?
Q1: Which operator is used for exponentiation in JavaScript?
Q2: What will 5 == "5" return?
Q3: Which operator checks both value and data type?
Q4: What is the result of "5" + 3 in JavaScript?
Q5: Which of the following is a logical OR operator?
Q6: What will the expression typeof 42 return?
Q7: Which operator is used to assign a value to a variable?
Q8: Which operator is used to compare value only (not type)?
Q9: What does the ! operator do in JavaScript?
Q10: What will true && false evaluate to?