JavaScript - Introduction and Terminology

Computer programming is a broad term that is can be defined as creating an executable computer program to accomplish a task or solve a problem. Programming includes concepts such as how to store data in computer memory, the logic of structured decisions, and powerful tools to enable large-scale repetition and iteration. Humans excel at logic and problem solving, but are very slow. Computers excel at doing things very quickly. The computer programs you use every day, also called software applications or simply apps, are the result of combining human logic and problem solving capabilities with the lightning speed of computers. There are many popular programming languages in use today, including C++, Java, Python, and PHP just to name a few.

JavaScript is considered a programming language, but the 'script' part of its name caries a special meaning. Scripting refers to writing programming code to provide instructions to software applications that are already built and running. That is, one might use a programming language such as C++ or Java to build a software application such as a Web browser, which requires some very complicated programming. Once the browser is installed, one can use a scripting language such as JavaScript to provide additional instructions to the Browser, such as what sequence of instructions are executed when a user clicks a certain button in a Web page. Another common example of scripting is using Visual Basic Script (VB Script) to create macros for Microsoft Word or Excel. A macro is usually a short script that automates a task like transforming one format of spreadsheet into a different format. It can be quicker for a human to write some scripting code to tell the software how to repeat a sequence of actions over and over, rather than the human manually having to perform those actions over and over again.

There are other examples of apps that can be scripted, but this lesson focuses on scripting Web browsers using Javascript. Scripting a Web browser often involves providing detailed instructions for what sequence of instructions should be executed when a user event occurs in a Web page. Common user events include clicking on something, passing the mouse over/out of a region of a page, or dragging the scrollbar. The browser's reaction to the user event is determined by a pre-programmed chunk of JavaScript code. This is typical of how JavaScript is used to create interactive capabilities in Web pages. To sum this up, scripting is a special type of programming that involves giving instructions to a running software app, rather than the type of programming that creates the app in the first place.

It is very important to contrast programming or scripting with the HTML/CSS portion of the course. HTML/CSS are markup/presentation languages that say what structure something has (HTML Table) or what something should look like (style class). Such markup/presentation languages are very different from programming (or scripting) languages. Programming involves things like storing data in computer memory and making decisions using logic conditionals. As you shall see, that is very different from simply specifying what something should look like.

The main objective of the remainder of this course is to learn the very basics of using JavaScript to provide custom reactions to user events in Web pages as described above. That is often called event-driven programming. This course assumes that students have no prior programming experience at all. Thus, the JavaScript Lessons progress slowly and first present some topics that every beginning programmer must understand (regardless of the programming language being used). The first two JavaScript lessons introduce some interactive programming fundamentals using a programming methodology called input/output programming. With the proper fundamentals in place, the lessons then turn to the fundamentals of event-driven programming. The two programming methodologies are summarized below:

Input/Output Programming - the traditional programming model for processing data.
  1. Acquire Input (data) from the user.
  2. Process the data in some way.
  3. Provide Output (feedback) to the user.

Event-Driven Programming - a newer programming model for interactive User Interface (UI) programming.
  1. Create custom reactions to user events such as clicks, mouseovers, etc.
  2. Wait for user events to occur to trigger the custom reactions.