Javascript 1
Javascript 1
Request a Page
Your local Server
computer with computer with
web browser web server
software software
Sends Requested
Page
•The most common use of web servers is to host websites. but there
exists other web servers also such as gaming, storage, FTP, email etc. A
web server can host hundreds of web sites.
•The primary job of a web server is to deliver web pages to clients.
•The communication between the client node and server node takes place using the
Hypertext Transfer Protocol (HTTP).
• The delivered web pages include images, style sheets and scripts in addition to text
content
•A web server is a physical computer or piece of hardware that delivers content or
services to end users over the Internet.
•Web server is a computer where the web content is stored.
•Types \examples of web servers
1.Apache web server
•One of the most popular and open source web server in the world developed
by the Apache Software Foundation. Runs on all operating systems
2.IIS web server
IIS stands for Internet information services.
•It is developed by Microsoft but it is not open source.
•it works with all the windows operating system platforms
•JavaScript is a very powerful client-side scripting
language.
•Used mainly for enhancing the interaction of a user with
the webpage \to make webpage more interactive.
•Apart from client side validation JavaScript is also being
used widely in game development and Mobile application
development.
•JavaScript was developed by Brendan Eich in 1995.
•Initially called Live Script and was later renamed
JavaScript.
1.Client side validation
2.Manipulating HTML Pages -
3.User Notifications\ pop-up windows and dialog boxes
4.Back-end Data Loading -
5.Presentations
6. Web Applications
7. Games
8.Smartwatch Apps
9. Mobile Apps
10.For making server applications
11.Dynamic drop-down menu
12.Displaying date and time
13.Displaying clocks etc.
•JavaScript can be implemented using JavaScript statements
that are placed within the <script>... </script> tags in a web
page.
•It is recommended that you should keep it within
the<head>tags.
• A simple syntax of your JavaScript will appear as follows.
<script ...>
JavaScript code
</script>
•The <script> tag alerts the browser program to start
interpreting all the text between these tags as a script
•Language: This attribute specifies what scripting language you are
using. Typically, its value will be JavaScript.
•Type: This attribute is what is now recommended to indicate the
scripting language in use and its value should be set to
“text/javascript".
•Src: Specifies the location of an external scripting file. The .js
extension is normally used for JavaScript code files.
So your JavaScript syntax will look as follows.
<script language="javascript" type="text/javascript">
JavaScript code
</script>
Note- The language and type attributes are now optional. we
can execute javascript code without using this attributes also.
In this example, JavaScript is embedded within the header. As soon as the page
is loaded this code is executed.
<html>
<head>
<title>JavaScript Example</title>
<script>
</script>
</head>
<body>The body</body>
</html>
a=10; Variable
b=20; Initialization
/*variable c is used to store the result of addition of a and
b*/
c= a+b;
document.write(c);
</script>
Constants in JavaScript
constants are special kind of variable used to
store value that can be e never change during
the execution of program
const keyword is used to to declare a constant
Syntax-
const nameofconstant =value ;
Example
const SSCMarks=89;
Data type are used to specify that what kind of
data is to Store in the variable.