Web Scripting - Java Script: Chapter - 3
Web Scripting - Java Script: Chapter - 3
Introduction
JavaScript is an interpreted computer programming language. It was originally implemented as
Part of web browsers so that client-side scripts could interact with the user, control the browser,
Communicate asynchronously, and alter the document contents.
Nowadays, JavaScript has become very useful in both game development and the creation of desktop
applications.
JavaScript was developed in 1995 by Brendan Eich, at Netscape, and first released with
Netscape 2 early in 1996. It was initially called as Live Script, but was renamed as JavaScript in
order to capitalize the popularity of Sun Microsystem's Java language. JavaScript's use in applications
outside of web pages also like in PDF documents, site-specific browsers, and
desktop widgets and other useful applications.
JavaScript was formalized in the ECMAScript language standard and is primarily used as part of
a web browser (client-side JavaScript). This enables programmatic access to computational
objects within a host environment. JavaScript very quickly gained widespread success as a
client-side scripting language for web pages. Microsoft introduced JavaScript support in its own
web browser, Internet Explorer, in version 3.0, released in August 1996.
Core JavaScript contains a core set of objects such as Array, Date, Math, and a core set
of language elements such as operators, control structures, and statements. Core
JavaScript can be extended for a variety of purposes by supplementing it with additional
objects.
Features of JavaScript
Browser Support
All browsers have accepted JavaScript as a scripting language and provide integrated
support for it. For example, to access flash content, you need to install flash plug-in in your
browser. But to use JavaScript, you don't have to use any plug-in at all.
Run-time Environment
JavaScript typically relies on a run-time environment (e.g. in a web browser) to provide
objects and methods by which scripts can interact with "the outside world". In fact, it relies
on the environment to provide the ability to include/import scripts (e.g. HTML <script>
elements). This is not a language feature as such but it is common in most JavaScript
implementations.
Vendor-specific Extensions
JavaScript is officially managed by Mozilla Foundation, and new language features are
added periodically. However, only some JavaScript engines support these new features.
Object Type
JavaScript supports the development of object types and in this context JavaScript
supports both predefined and user-defined objects. It is possible to assign objects of any
type to any variable. It is possible to instantiate the defined object types to create object
instances in JavaScript, which is a very powerful feature of Object based language.
Object Instantiation
In order to carry out the process of creating specific object instances available in
JavaScript, you can make use of a new operator. These two powerful, object-based
features supported by JavaScript described above make this an object model language. In
JavaScript, the object types are defined by properties and methods. Properties of Objects
are used to access the data values contained in an object. You can make use of the
properties of JavaScript objects for editing as well as reading depending on the object’s
nature. That is, if you want to carry out functions on the object, this is achieved by using
methods that make use of the object’s properties.
Why JavaScript?
JavaScript is a simple scripting language invented specifically for use in web browsers to
make websites more dynamic. On its own, HTML is capable of outputting more-or-less
static pages. Once you load them up your view doesn't change much until you click a link
to go to a new page.
Adding JavaScript to your code allows you to change how the document looks completely, from changing
text, to changing colours, to changing the options available in a drop-down list and much more.
JavaScript is a client-side language, which means all the action occurs on the client's
(reader's) side of things. This means that no trips to the server are required for JavaScript
to kick into operation, which would slow down the process enormously.
JavaScript operations are usually performed instantaneously. In fact, JavaScript is often used to
perform operations that would otherwise encumber the server, like form input validation.
This distribution of work to the relatively quick client-side service speeds up the process
significantly.
This access to information gives JavaScriptgreat power to modify the browsing experience. They can also
react to events, such aswhen the user clicks their mouse, or points to a certain page element. This is also a
verypowerful ability.
Browser Compatibility
JavaScript is supported by Netscape 2+, Internet Explorer 3+, Opera 3+ and most of the
other modern web browsers. Each new version of the main browsers has supported new
generations of JavaScript commands, each more complex than the earlier one. However,
script compatibility can still be a problem, as the language is not as standardised as
HTML.