Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
284 views
in Enterprise Resource Planning by (30.5k points)
closed by

Explain operators in JavaScript.

1 Answer

+1 vote
by (30.4k points)
selected by
 
Best answer

Operators in JavaScript. Operators are the symbols used to perform an operation 

1. Arithmetic operators: It is a binary operator. It is used to perform add i-tion (+), subtraction(-), division(/), multiplication(*), modulus(%-gives the remainder), increment(++) and decrement(—) operations. 

Eg. If x = 10 and y = 3 then

If x = 10 then 

document.write(++x); → It prints 10+1=11 

If x = 10 then 

document.write(x++); → It prints 10 itself. 

If x = 10 then 

document.write(—x); It prints 10-1=9 

If x = 10 then 

document.write(x—);→ It prints 10 itself.

2. Assignment operators: 

If a = 10 and b = 3 then a = b. This statement sets the value of a and b are same,i.e. it sets a to 3. It is also called short hands

If X = 10 and Y = 3 then

3. Relational(Comparison) operators:

It is used to perform comparison or relational operation between two values and returns either true or false. 

Eg: lf X = 10 and Y= 3 then

4. Logical operators: 

Here AND(&&), OR(||) are binary operators and NOT(!) is a unary operator. It is used to combine relational operations and it gives either true or false 

If X = true and Y= false then

Both operands must be true to get a true value in the case of AND(&&) operation If X = true and Y = false then

Either one of the operands must be true to get a true value in the case of OR(||) operation If X = true and Y = false then

  !X   !Y
false   true

5. String addition operator(+): 

This is also called concatenation operator. It joins (concatenates) two strings and forms a string. 

Eg: 

var x, y, z; 

x= “BVM HSS”; 

y= “Kalparamba”; 

z = x + y; 

Here the variable z becomes “BVM HSS Kalparamba”. 

Note: If both the operands are numbers then addition operator(+) produces number as a result otherwise it produces string as a result. Consider the following.

Eg:

  • 8(number) + 3(number) = 11 (Result is a number) 
  • 8 (number)+ “3”( string) = “83″ (Result is a string) 
  • “8” (string) + 3 (number) = “83”(Result is a string) 
  • “8” (string) + “3” (string) = “83” (Result is a string).

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...