You are on page 1of 8

Java Script

The Advantage of Java Script


• An interpreted language
JavaScript is an interpreted ;language, which requires no compilation
steps. This provides an easy development process. The syntax is
completely interpreted by the browser just as it interprets HTML tag.
• Embedded within HTML : JavaScript does not require any special
or separate editor for programs to be written, edited or compiles. It
can be written in any text editor like notepad, along with appropriate
HTML tags, and saved as filename.html.
HTML files with embedded JavaScript commands can then be read
and interpreted by any browser that is JavaScript enabled.
• Minimal Syntax-Easy to Learn : By learning just a few commands
and simple rules of syntax , complete applications can be built using
JavaScript.
The Advantage of Java Script
• Quick Development : Because JavaScript does not require time-consuming
compilations , script can be develop in a short period of time. This is enhanced
by the fact that many GUI interface features, such as alerts, prompts, confirm
boxes and other GUI elements are handled by client side JavaScript,browser
and HTML code
• Design for simple, small Programs: it will be suited to implement simple,
small program. The program can be easily written and executed at an
acceptable speed using JavaScript. In addition they can be easily integrated into
a web page.
• Performance: JavaScript can be written such that the HTML files ate fairly
compact and quite small. This minimize strong requirements on the web server
and download time for the client.
• Procedural Capabilities : every programming language needs to support
facilities such as condition checking, looping and branching, JavaScript
provide syntax which can be used to add such procedurals capabilities to the
web page.
The Advantage of Java Script
• Design for programming User Events: JavaScript support Object/Event based
programming JavaScript recognize when a form Button is pressed. This event can
have suitable JavaScript code attached, which will execute when the Button
Pressed event occur.
• JavaScript can be used to implement context sensitive help. Whatever an HTML
form’s Mouse cursor Moves Over button or a link on the page, helpful and
informative message can be displayed in the status bar at the button of the browser
window.
• Easy Debugging and Testing : Being an interpreted language, script in
JavaScript are tested line by line, and error are also listed as they are encountered.
• Platform independence /architecture Neutral.: JavaScript is a programming
language that is completely independent of the hardware on which works. It is
language that understood by any JavaScript enable browser.
• The fact that a platform specific browser, maintained at the client ends, does the
interpretation of JavaScript relieves the developer of the responsibility of
maintaining multiple source code files for multiple platforms.
Methods of using JavaScript

• JavaScript can be embedded in HTML


documents i.e. in <head>, in <body> or in
both tag
• Javascript can reside in separate page.
• Javascript object attributes can be placed in
HTML element tags.
Eg : <body onLoad=“alert(‘Hello’)”>
External Java Script :
• A script on several pages without writing
the script on each and every page.
• You can write a script in external file &
save the file with .js extension.
Eg:
document.write(“This script is the example
of external java script”);
• External script can not contain the <script>
tag.
• You can call this external script using src
attribute from any of your pages.
Example :
ExternalJS.html
<html>
<head>
<title>Example of external Java Script </title>
</head>
<body>
<script language=“javascript” src=“ext.js”>
</script>
<p>
The actual script is in an external script file
called “ext.js".
</p>
</body>
</html>

ext.js
document.write(“ This is the example of
external Java Script ”);

You might also like