Responsive image
Responsive image

Java Script

JavaScript is the most popular scripting Language on the internet, and works in all major browsers, such as internet Explorer, Firefox, chrome, opera and safari etc. It is case Sensitive.
Comments:
Single line comments start with  //.
And multi line comment start with  /* and end with */.

Responsive image

Operators in Javascript

Operators (Arithmetic)
+   Addition, -   subtraction, *    Multiplication, /    division, %   modulus(Remainder), ++ Increment, --   Decrement

Assignment Operators ( x=10, y=5)

Operator     example                same as                result
=                 x=y                                                   False
+=               x+=y                    x=x+y                  x=15
-=                x-=y                     x=x-y                   x=5
*=               x*=y                     x=x*y                   x=50
/=                x/=y                      x=x/y          x=2
%=              x%=y                   x=x%y                 x=0

Comparison Operators (x=5)
Operators             Description          Example    
==                        is equal to                       x==8 Is false
!=                         is not equal to                x!=8 is true
>                           is greater than                x>8   is false
<                           is less then                      x<8   is true
>=               is greater than or equal to        x>=8 is false
<=               is less than or equal to   x<=8 is true

Logical operators (x=6 and y = 3)
Operator              Description          example      
&&                       and                       (x<10 && y>1) is ture
||                           or                         (x==5 || y==5) is false
!                            not                        !(x==y) is true

How to write the JavaScript in Notepad?
<html>
<head>
<title>First JavaScript page</title>
</head>
<body>
<SCRIPT LANGUAGE=”JavaScript”>
//<script type=”text/javascript”>
document.write(”Wel come to My First Page”);
document.write(”<br> Thanks”);

</SCRIPT>
</body>
</html>

document.write: The document.write command is a standard javascript command for writing output to a page.

Variables:
Variables are “ containers” for storing information.

Variable name are case sensitive (y and Y are different variable)

Example:
<html>
<body>
<SCRIPT LANGUAGE=”JavaScript”>
var day=1;
switch(day)
{
case 1:
document.write(“Sunday”);
break;
case 2:
document.write(“Monday”);
break;
case 3:
document.write(“Tuesday”);
break;
case 4:
document.write(“Wednesday”);
break;
case 5:
document.write(“Thursday”);
break;
case 6:
document.write(“Friday”);
break;
case 7:
document.write(“Saturday”);
break;
default:
document.write(“ This is wrong day’s no.”);
}
</SCRIPT>
</body>
</html>



Post Your Comment Here