Thomas Valentine
What is JavaScript?
January 26, 2009
|
Welcome to The JavaScript Chronicles where we'll cover
JavaScript from A-Z. So strap-on your thinking cap and open your favorite text editor, because it's time to get started.
|
JavaScript is the workhorse of the common Internet page. It
is used to carry out the higher, more advanced functions
inherent to more and more of today's web pages. With it you
can interact with the user input for an HTML FORM control,
for instance. There are many visual effects you can
accomplish using JavaScript such as flying banners, fades,
and other effects. Your skill level and creativity are the
only limits to what you can accomplish. I'll give you the
skills; you have to provide the imagination.
After the creation and widespread acceptance of the
Internet, the makers of the standards we use today realized
that there was a huge hole in the capabilities of the online
web browser. CGI (Common Gateway Interface) scripting had
become the practice for processing user input, but it took
its toll on the servers used to process the commands,
raising the cost of doing business. This cost was addressed
and partly solved with the creation of JavaScript, which was
first intended to relieve server load by processing some of
the common user input into a form the server could use. Some
examples are verification and validation of user input.
Verifying a five digit zip code or six digit postal code are
very common applications of JavaScript. The server load was
therefore reduced by executing some of the code - that was
previously in the CGI script on the server - on the user's
machine.
JavaScript is Object Oriented, meaning that you create an
object with a certain set of properties that does a certain
thing. You then re-use it as many times as you have a need
for. This object oriented architecture is what all new and
semi-new languages are migrating to - it solves many of the
problems of the older "inline" languages which start
processing from the top and work down the list of commands.
These inline languages are slow and tedious, and are of
limited capability. Object Oriented languages solved the
problems inherent to this form of programming by making its
objects available to the rest of the script.
The modular programming style of the Object Oriented
approach involves keeping about three different rules in
mind. Take a look.
- Create your object with an eye toward re-using it later.
- Identify common, repetitive tasks and make the object to do them.
- These identified common tasks, now objects, are placed
in external library files of .js or .mocha extensions.
Placing the re-usable code in an external file makes it
available to the rest of your site content through the use
of an HTML LINK tag. This is advantageous because you need
only change the contents of one file to make a change or
revision. The alternative is to place the script in every
file, creating the need to make changes or revisions in
every single file on your web site that uses the code. You
can see the advantages of this approach, which was inspired
by the CSS external style sheet.
Another great advantage of JavaScript is its platform
independence - it can run on almost any machine created
because its specifications don't change from platform to
platform. There are some inherent inconsistencies, but as a
whole the language is interpreted in much the same way. Keep
in mind that errors by programmers create a huge array of
some very strange inconsistencies on each platform. Some can
be used in an advantageous way, while others severely limit
the capabilities of certain objects.
The JavaScript Chronicles
JavaScript Security - Page 2
The JavaScript Chronicles
JavaScript Introduction
Part 2: Data Types
Part 3: Arrays
Part 4: Operators
Part 5: Conditional Statements
Part 6: JavaScript Functions
Part 7: Pattern Matching - The RegExp Object
Part 8: Introduction to Server Side JavaScript
Part 9: Server Side JavaScript Mail Sending
Part 10: Server Side JavaScript and File Manipulation
Part 11: Working with Forms in JavaScript
Part 12: Getting to Know Dynamic HTML
|