Skip navigation

What is JavaScript?

While HTML and CSS are integral parts of the web design process it is their use in concert with JavaScript that allows the creation of interactive websites. The use of JavaScript with the DOM even allows JavaScript scripts to modify CSS properties creating highly dynamic web pages.

While JavaScript was originally only designed to provide programming capabilities at both the server and client ends, JavaScript has evolved into a fully functional programming language.[1]

Incorporating JavaScript

JavaScript is included in XHTML documents is one of two main ways: explicit embedding or implicit embedding.

  • Explicit Embedding: In this case the JavaScript Scripts are included in the XHTML document and form part of either the header or body (depending on the content of the Script). This method is not without disadvantages, especially that of having two kinds of code in the one document.
  • Implicit Embedding: In this case the JavaScript Scripts are stored in an external document that is linked from the XHTML document. This approach overcomes many of the pitfalls associated with explicit embedding.

Uses of JavaScript

JavaScript can be employed in a number of different ways on a web page.  Some common examples most users would have already come across include

  • Images that change when you move the mouse over them
  • Slideshow animations
  • Input forms with pop-up messages
  • Customised messages for return visitors to websites
  • Pop up warnings and confirmations
  • Calculation areas

There are several blogs that have complied lists of examples of websites that make good use of JavaScript including this one, which lists 50 examples of the exceptional use of JavaScript –

Basic Operators

According to McGrath[2], JavaScript has a number of operators the most useful of which are list below.

+ Addition/String addition
* Multiplication
/ Division
% Modulus

Complex Operators

+= Addition/String addition with Assignment
-= Subtraction with Assignment
*= Multiplication with Assignment
/= Division with Assignment
%= Modulus with Assignment
++ Pre/Post Increment
Pre/Post Decrement

Comparison Operators

< Less than
<= Less than or Equal to
> Greater than
>= Greater than or Equal to
!= Not Equal to
== Equal to

Logical Operators

&& Logical AND
|| Logical OR
! Logical Negation
?: Ternary Operator

[1] Sebesta, Robert (2009) Programming the World Wide Web 2009

[2] McGrath, Mike (2009) JavaScript in Easy Steps

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: