Intro to JavaScript

JavaScript is a programming language

Programming languages let humans give computers instructions by writing words and symbols

Computers aren’t that smart, so programming languages have to be very structured and explicit

Please multiply 3 by 4, then subtract 2 and print the result

var result = 3 * 4 - 2;
console.log(result);

A brief history of the web

The Web was invented by Tim Berners-Lee in 1990.

At first web pages consisted of only HTML.

HyperText Markup Language

HTML is a programming language that lets humans describe the structure and content of a webpage. It’s the basis of everything on the Web.

<h3>HyperText Markup Language</h3>

<p>
HTML is another programming language designed to describe a document. It's the
basis of <em>everything</em> on the Web.
</p>

Cascading Style Sheets

CSS is another programming language invented so people could separately describe how their webpages should look.

h3 {
font-size: 1.75rem;
font-weight: bold;
}

JavaScript

Finally JS was created so people could dynamically change their webpages. It makes webpages interactive.

var myButton = document.querySelector("button");

function changeButtonText() {
myButton.textContent = "You just clicked me!";
}

myButton.onclick = changeButtonText;

HTML & CSS & JS

Each of the three Web languages fulfill a different purpose:

  1. HTML is the nouns. It describes what things are on the page
  2. CSS is the adjectives. It describes what the things look like
  3. JS is the verbs. It tells the page what to do

HTML & CSS are very focused. They are languages designed to achieve a single goal.

JS is a general purpose language—it can do almost anything a computer can do. It’s more powerful, but has more syntax to learn than HTML or CSS.

That doesn’t mean you should neglect HTML or CSS though. JS wouldn’t do anything without an HTML page to run on!

Live coding time!