Explain Operators in Javascript?

Java script has two types of operators those used in test of logic and those used to effect variables.

Plus (+ ):- If the arguments are numbers. Then they are added together. If the arguments are strings then they are concatenated.

Minus( – ):- If supplied with two operands. This operator subtracts one from the other. if supplied with a single operator it reverses it’s sign.

Star(*):- Multiplies two numbers.

 / :- Divides the first number by the second.

 %:- Modular division returns the integer remainder from the division.

Greater than(>):- If the left operand is grater than the right operand it returns true.

Less than (<):- If the left operand is less than right operand then it returns true.

Greaterthan or Equal to(> =):- It returns true if the left operand is greater than (or) equal to the right one.

Lessthan or Equalto(<=):- Is lessthan true if the left operand is lessthan  (or) equal to the right one.

= = :- Returns true if the two operands are equal.

! = :-Returns true if the two operands are equal.

Logical and (&&) :-This logical operator returns true if two operands are true.

Logical or(||):- Logical or returns true if ne (or) more the operands are ture.

Equal to (=):- Assign the value to the variable.

+ = :- Add two numbers then assign the result to the one of the left of the expression.

Increment operator (+ +):- Auto increment increases value of its argument by one.

Decrement operator (– –):- Auto decrement decreases the value of it’s argument by one.

New operator:-It is use full to create objects of specific class (or) predefined class dynamically.

Syntax:- var ref = new classname ( );

Eg:-  var d = new date( );
         d.getMonth( );

Syntax:- ref. methaodname( );   
               ref. variablename ( );

Conditional operator:- This operator assign some value to a variable based on condition.

Syntax:-  var1 =  (condition)?var2 : var 3;

Eg: var a = 10;
       var b = 20;
       var c=( a > b ) ? a : b ;

Related

Web Technology 791632992859458671

Post a Comment

emo-but-icon

item