Javascript: 4/24/2019 1 Hassan Khan
Javascript: 4/24/2019 1 Hassan Khan
JavaScript
What is JavaScript?
1
4/24/2019
Example
<html>
<body>
<script type="text/javascript">
document.write("This is my first JavaScript!");
</script>
</body>
</html>
2
4/24/2019
Example
3
4/24/2019
How To Use?
4
4/24/2019
JavaScript Statements
document.write("Hello");
document.write("Hello")
JavaScript Comments
5
4/24/2019
JavaScript Variables
JavaScript variables are used to hold values
or expressions.
x=5, y=6, z=x+y
Rules for JavaScript variable names:
Variable names are case sensitive (y and Y
are two different variables)
Variable names must begin with a letter or
the underscore character
JavaScript Variables
Declaration
var x;
var carname;
Assign Values
x=5;
carname=“Toyota";
6
4/24/2019
Y=5
x = 5 and y=10
7
4/24/2019
Comparison Operators
8
4/24/2019
Logical Operators
If...Else Statements
9
4/24/2019
Example (If)
Example (If...else)
10
4/24/2019
Example(If...else if...else)
Switch Statement
11
4/24/2019
Example (Switch)
Popup Boxes
Alert Box
alert(“Hello Every Body");
Confirm Box
confirm(“Press a button");
Prompt Box
prompt("Your name","")
Hassan Khan
4/24/2019 24
12
4/24/2019
Functions
Example (Function)
13
4/24/2019
JavaScript Loops
14
4/24/2019
While Loop
15
4/24/2019
JavaScript Events
16
4/24/2019
Events
JavaScript Objects
17
4/24/2019
search()
toLowerCase()
toUpperCase()
18
4/24/2019
Date Comparison
19
4/24/2019
Math.PI
Math.E
Math.sqrt(number)
Math.round(4.7)
20
4/24/2019
Navigator.appName;
Navigator.appVersion
21