What is JavaScript?

In this lesson, students will learn:

  • How to write their first JavaScript program.
    • How to add JavaScript to a page
    • How to attach an external javascript file
    • How to get information about an error in the console

JavaScript programs are also called scripts. Inside the <script> region is a simple JavaScript statement. Each one should start on a new line and end with a semicolon (;).

A statement makes up the logical set of instructions that tells the browser what to do. The word alert() is a function and, 'hello world' is a string.

Error Console

The most basic method to track JavaSrcipt errors is to consult the web browser. Most web browsers record in a separate window called an error console. When you load a web page that contains an error, you can then view the console to get helpful information about the error, such as, which line of the web page it occurred in and out and a description of the error.

Chrome JavaScript Console
Click the customize menu button and choose Tools⟶JavaScript Console.
Keyboard shortcut: Ctrl+Shift+J (Windows) or ⌘-Option-J (Mac).

Internet Explorer Console
Press the F12 key to open the developer tools, and press it again to close them.
You’ll find JavaScript errors listed under the Console tab.

Firefox JavaScript Web Console
On Windows click the Firefox tab in the top left of the browser window and choose Web Developer⟶Web Console.  On Mac, select Tools⟶Web Developer⟶Web Console.
Keyboard shortcut: Ctrl+Shift+I (Windows) or ⌘-Option-K (Mac).

Safari Error Console
Developer menu: Developer⟶Show Error Console.  Keyboard shortcut:  ⌘-Option-C (Mac).