TechnoJavaScript
TechnoJavaScript
WEST BENGAL
JavaScript
1
TECHNO INDIA UNIVERSITY
WEST BENGAL
NOTES:
• JavaScript was initially created to “make web pages alive”.
• The programs in this language are called scripts. They can be written right
in a web page’s HTML and run automatically as the page loads.
• Scripts are provided and executed as plain text. They don’t need special
preparation or compilation to run.
• In this aspect, JavaScript is very different from another language called2Java.
TECHNO INDIA UNIVERSITY
WEST BENGAL
JavaScript
3
TECHNO INDIA UNIVERSITY
WEST BENGAL
Features of JavaScript:
4
TECHNO INDIA UNIVERSITY
WEST BENGAL
Application of JavaScript
• Client-side validation,
Example:
<html>
<body>
<h2>Hello BCS3B Welcome to JavaScript</h2>
<script>
document.write("Hello JavaScript by JavaScript");
</script>
</body>
</html>
6
TECHNO INDIA UNIVERSITY
WEST BENGAL
JavaScript Example
<script type="text/javascript">
document.write("JavaScript is a simple language for javatpoint learners");
</script>
<script type="text/javascript">
alert("Hello Javatpoint");
</script>
8
TECHNO INDIA UNIVERSITY
WEST BENGAL
9
TECHNO INDIA UNIVERSITY
WEST BENGAL
10
TECHNO INDIA UNIVERSITY
WEST BENGAL
message.js index.html
12
TECHNO INDIA UNIVERSITY
WEST BENGAL
13
TECHNO INDIA UNIVERSITY
WEST BENGAL
JavaScript Variable
• A JavaScript variable is simply a name of storage location. There are two
types of variables in JavaScript : local variable and global variable.
• There are some rules while declaring a JavaScript variable (also known as
identifiers).
• After first letter we can use digits (0 to 9), for example value1.
• JavaScript variables are case sensitive, for example x and X are different
variables.
14
TECHNO INDIA UNIVERSITY
WEST BENGAL
15
TECHNO INDIA UNIVERSITY
WEST BENGAL
var value=50;
function a()
{
alert(window.value);//accessing global variable
}
18
TECHNO INDIA UNIVERSITY
WEST BENGAL
JavaScript primitive data types: There are five types of primitive data types in JavaScript.
Data Type Description
String represents sequence of characters e.g. "hello"
Number represents numeric values e.g. 100
Boolean represents boolean value either false or true
Undefined represents undefined value
Null represents null i.e. no value at all
JavaScript If-else
• If Statement
• If else statement
• if else if statement
21
TECHNO INDIA UNIVERSITY
WEST BENGAL
22
TECHNO INDIA UNIVERSITY
WEST BENGAL
23
TECHNO INDIA UNIVERSITY
WEST BENGAL
<script> <script>
var i=11; var i=21;
while (i<=15) do{
{ document.write(i + "<br/>");
document.write(i + "<br/>"); i++;
i++; }while (i<=25);
} </script>
</script>
25
TECHNO INDIA UNIVERSITY
WEST BENGAL
26
TECHNO INDIA UNIVERSITY
WEST BENGAL
JavaScript Objects
A javaScript object is an entity having state and behavior (properties and
method).
Thank You
32