Java script operator -: Like any other language java script is supporting many type operator . These are
Arithmetic operator-: Arithmetic operator use to calculate the value of mathematics operators as like addition, subtraction, multiplication, division, modules,increment,and decrements as like
- Addition -: It add the value and sign of this (+) example x=2; y=3; x+y=5; result
- Subtraction-: It subtraction the value and sign of this (-) like it x=7; y=3; x-y=5; result
- Multiplication -: It Multiplication the value and sign of this (*) example x=2; y=3; x*y=6; result
- division -: It division the value and sign of this (/) example x=18; y=3; x/y=6; result
- Modules -: It modules the value and sign of this (%) it is a division remainder of the value example x=20; y=3; x%y=2; result
- Increment -: It increment the value and sign of this (++) . It add one in any value example x=15; x++=16; result
- Decrement-: It decrease the value and sign of this (–) example x=18; x–=17; result
Assignment operator-: It assign the value means it compare the two value and show the relation between them.example x=y; These are same
Comparison operators -: This operators is use for comparison two value means it use equal or greater then or less then
== is equal to when value is same a=b;
!= is not equal when value is not same a!=b;
> greater then when a is greater then b . a>b;
< less than when a is less then b. a<b;
>= greater then equal a>=b; a is big or equal
<= less then equal a<= b; a is less then b or equal
Logical operators-: Like c language in java script three type of logical operator and(&&), or(||) , not(!) example if x=6 and y=4 the operators is use like this way
(x<10 && y>1) returns true;
String operators in java script-: a string is most often text for a example “netnic”. To stick two or more string variables together use the + operator. txtname1=” Tips and technic”; txtname1=”of computer and internet” ; txtname3=txtname+txtname;
the variable txtname3 now contains ” Tips and technic of computer and intenet:.
Condition operator-: java script also contains a conditional operators that assign a value to a variable based on some condition as like varibalename =(condition)?value1:value2;
example-: greeting=(visitors==”PRES”)?”Dear sir”:”hello”;
result-: If the variable visitors is equal to PRES, then put the string ” Dear sir” in the variable named greeting. if the variable visitor is not equal to PRES, then put the string name “hello” into the variable name greeting .
Conditional operator-: when we write the code we want to different actions for different decision. here we can use conditional operation as like If Statement-: this statement was written when we want to execute some code as like
<html>
<head>
<title>tips and technic of computer and internet</title>
</head>
<body>
<Script language=”javascript” type=”text/javascript”>
// write a “good morning ” greeting if
//the is less then 10
var d=new Date()
var time=d.getHours()
if(time<10)
{
document.write(“<b> Good morning</b>”)
}
</script>
</body>
</html>
If ….else statement -: This condition is when one condition is true and another is false as like
<html>
<head>
<title>tips and technic of computer and internet</title>
</head>
<body>
<Script language=”javascript” type=”text/javascript”>
// write a “good morning ” greeting if
//the is less then 10
var d=new Date()
var time=d.getHours()
if(time<10)
{
document.write(“<b> Good morning</b>”)
}
false
{
document.write(“<b> Good day</b>”)
}
</script>
</body>
</html>
If….else …if…else statement- it is called nested if…else condition example of this
<html>
<head>
<title>tips and technic of computer and internet</title>
</head>
<body>
<Script language=”javascript” type=”text/javascript”>
// write a “good morning ” greeting if
//the is less then 10
var d=new Date()
var time=d.getHours()
if(time<10)
{
document.write(“<b> Good morning</b>”)
}
else if(time >10 && time <16)
{
document.write(“<b> Good day </b>”)
}
else
{
document.write(“<b> hello netnic </b>”)
}
</script>
</body>
</html>