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);
The Web was invented by Tim Berners-Lee in 1990.
At first web pages consisted of only HTML.
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>
CSS is another programming language invented so people could separately describe how their webpages should look.
h3 {
font-size: 1.75rem;
font-weight: bold;
}
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;
Each of the three Web languages fulfill a different purpose:
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!