Javascript


Related applications


Search a word:
   



© The scientific sentence. 2010


Operators



1. Arithmetic Operators:


+ 	Addition 	
- 	Subtraction 	
* 	Multiplication 	
/ 	Division 	
% 	Modulus (division remainder) 
++ 	Increment 	
-- 	Decrement

2. Assignment Operators:


= 	x=y 	  	
+= 	x+=y 	x=x+y 	
-= 	x-=y 	x=x-y 	
*= 	x*=y 	x=x*y 	
/= 	x/=y 	x=x/y 	
%= 	x%=y 	x=x%y

Example:

<script type="text/javascript">
<!--
document.writeln('<BR> <h3>Mathematics operations</h3>');
var x = 6;
var y = 4;
document.writeln('x = ' + x + ', y = ' + y + '<br>');
document.writeln('x + y = ' + (x+y) + '<br>');
document.writeln('x - y = ' + (x-y) + '<br>');
document.writeln('x / y = ' + (x/y) + '<br>');
document.writeln('x % y = ' + (x%y) + '<br>');
document.writeln('Math.min(x,y) = ' + Math.min(x,y) + '<br>');
// -->
</script>

The output is:

   
Note that we use the operator = to assign and the operator "+" to 
add numbers or to concatenate strings.

3. Comparison Operators:


== 	is equal to 	
=== 	is exactly equal to (value and type) 
!= 	is not equal 	
> 	is greater than 
< 	is less than 	
>= 	is greater than or equal to 
<= 	is less than or equal to 	

4. Logical Operators:


&& 	and 	
|| 	or 	
! 	not

5. Conditional Operator ?:

conditional operator assigns a value to a variable 
based on some condition.
 
Syntax
variable_name=(condition)?value1:value2 

Example:
x = (a==b)?y:z;

If the variable a has the value of b, then the variable x will 
be assigned the value y; else it will be assigned z.

  
Google
Web
ScientificSentence
 




chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2009. All rights reserved.