JavaScript is the interpreted scripting language introduced in the mid-90's that enabled web developers
to introduce dynamic web content, as opposed to mostly static pages, such as most of Wikipedia. Which
I'm currently reading to confirm when JavaScript was first introduced.
While HTML and CSS create the structure and style of web pages, JavaScript allowed for a single page to
respond to user actions. You could technically "fake" this without any kind of programming by creating
multiple static pages, with the user changes already built in. Such as clicking
this link to change the font color to red. But this comes with the obvious downside of (1) having
a fixed number of modifications (2) the lose of any data stored in forms and (3) complications that arise
from keeping each page up to date over time. So instead, we could use JavaScript to instantiate a much
wider array of changes, without having to change the currently loaded page.
Let's take a look at a simple example of this: a useless button.
Using this simple JavaScript function.
function change()
{
if (document.getElementById("slacker").innerHTML == "Slacker")
document.getElementById("slacker").innerHTML = "Anti-slacker";
else
document.getElementById("slacker").innerHTML = "Slacker";
}
Or you can click on this text
to change it's color. Up to three times!
For all the good it does for web development, it has... misgivings. For example, you might want to do
some math at some point. If you aren't careful to explicitly define your operands as integer values, you
can easily get 1 + 1 = 11.
For as much grief as people give JavaScript, it is one of the simpler ways to put some programming logic
into your webpages. It's very commonly supported by server platforms, as opposed to trying to get your
server configured to display ASP.NET pages... ... ...
I am very much still
salty about that.