An operator is used to perform specific mathematical or logical manipulations.
|+||Perform Addition Operation between two operands||10 + 2 =12|
|-||Subtracts||10 -2 =10|
|*||Multiply two operands||10*2 =20|
|/||Divide numerator by denumerator||10/2 =20|
|%||Return remainder of after an integer division||10%3=1|
|++||Increases integer value by one||10++=11|
|--||Decreases integer value by one||10--=9|
|+=||m +=n||m = m + n|
|*=||m *= n||m = m * n|
|/=||m/=n||m =m / n|
|%=||m %=n||m = m % n|
|<<=||m <<= n||m = m << n|
|>>=||m >>= n||m = m >> n|
A list of comparison operators is given below.Consider variable m holds 10 and variable n holds 2.
|==||equal to||(m == n) is not true.|
|===||equal value and equal type||(m === n) is not true.|
|!=||not equal to||(m != n) is true.|
|!==||not equal value or not equal type||(m !== n) is true.|
|>||greater than||(m > n) is true.|
|>=||greater than or equal to||(m >= n) is true.|
|<=||less than or equal to||(m <= n) is not true.|
A list of logical operators is given below.Consider variable m holds 10 and variable n holds 2.
|&&||Logical AND||(m && n) is true.|
|||||Logical OR||(m || n) is true.|
|!||Logical NOT||!(m && n) is false.|
|Logical AND||Logical OR||Logical NOT|
|true && true; //will retrun true||true ||true; //will retrun true||!true ; //will retrun false|
|true && false; //will retrun false||true || false; //will retrun true||!false ; //will retrun true|
|false && false; //will retrun false||false || false; //will retrun false||!false ; //will retrun true|
condition ? value1 : value2
var result = (mark >= 33) ? "pass" : "fail";
Above statement assigns the value "pass" to the variable result if mark is 33 or more. Otherwise, it assigns the value "fail" to result.