M1D19: JavaScript Basics

Syntax

  • A programming language’s commands, special words and punctuation.
  • The rules of the language, or vocabulary.

Program

  • a set of instructions that perform specific tasks when executed by the computer.

Console

  • often used to inspect the inner workings of your websites and applications.

Alert

  • a command that’s built into the browser. It opens a dialog box and displays a message.

JavaScript Statement

  • is just like a sentence, but ends in a ;

console.log()

  • prints a message to the console

document.write()

  • document represents the current web page, and write is a command that writes a message to the current web page.
alert("Hello. Thansk for visiting!");
console.log("Hello from the console.");
document.write("<h1>Welcome to my web page!</h1>");

Add JavaScript to HTML

  • HTML – Content
  • CSS – Syle
  • JavaScript – Interactivity

JavaScript Engine

  • A program (or interpreter) built into the browser that executes JavaScript code.

Running the Program

  • When a browser reads and acts on a JavaScript program, we call that running the program.
  • It’s also called, “executing the program.”

Linking a JavaScript file to an HTML file

<script src="js/script.js"></script>

Debug JavaScript in the Console

  • console

Leave a Reply