JS Operators

JavaScript operators are used to perform operations on variables and values. They are categorized into different types based on their functionality.

1. Arithmetic Operators

Used for mathematical calculations.

OperatorDescriptionExampleOutput
+Addition5 + 38
-Subtraction10 - 46
*Multiplication6 * 212
/Division10 / 25
%Modulus (Remainder)10 % 31
**Exponentiation (ES6)2 ** 38
++Incrementlet x = 5; x++6
--Decrementlet y = 5; y--4

Example:

let a = 10, b = 3;
console.log(a + b);  // Output: 13
console.log(a % b);  // Output: 1
console.log(a ** b); // Output: 1000

2. Assignment Operators

Used to assign values to variables.

OperatorDescriptionExampleEquivalent To
=Assignx = 5x = 5
+=Add & Assignx += 3x = x + 3
-=Subtract & Assignx -= 2x = x - 2
*=Multiply & Assignx *= 4x = x * 4
/=Divide & Assignx /= 2x = x / 2
%=Modulus & Assignx %= 3x = x % 3
**=Exponent & Assignx **= 2x = x ** 2


3. Comparison Operators

Used to compare values and return true or false.


Qus. 1 : When there is an indefinite or an infinity value during an arithmetic value computation in javascript

  1. Prints an exception error
  2. Prints an overflow error
  3. Displays “Infinity”
  4. Prints the value as such
Qus. 2 : The snippet that has to be used to check if “a” is not equal to “null” is

  1. if(a!=null)
  2. if (!a)
  3. if(a!null)
  4. if(a!==null)
Qus. 3 : What is the output of this expression? x = 2 + 2; document.write(x);

  1. 22
  2. 4
  3. 2
  4. syntax error
Qus. 4 : Which operator is used to assign a value to a variable?

  1. =
  2. x
  3. ==
  4. *
Qus. 5 : Which operator is used to assign a value to a variable in JavaScript?

  1. =
  2. ==
  3. ===
  4. !=

Programs

JavaScript code that calculates the squares and cubes from 0 to 10

View Solution


Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad