Q1. What Are Operators in JavaScript?
Operators are special symbols used to perform operations on values and variables. They help in calculations, comparisons, assignments, and logical decisions.
Example
Here, + is an operator used to add numbers.
Example
let sum = 5 + 3;Here, + is an operator used to add numbers.
Q2. Types of operators in JavaScript?
JavaScript has several types of operators:
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Increment and Decrement Operators
- Ternary Operator
- String Operators
- Type Operators
Q3. What is the Ternary Operator?
The ternary operator is a short way to write an if-else statement.
Example
Example
let age = 18;
let result = age >= 18 ? "Adult" : "Minor";console.log(result);Q4. What Are Type Operators in JavaScript?
Type Operators in JavaScript are operators that help you identify or work with the data type of a value or object. They are mainly used to check what kind of data you are dealing with or to verify relationships between objects and classes.
Example
Output
Example
console.log(typeof "Hello");Output
string