JavaScript Introduction
JavaScript is the programming language of the web. It makes pages interactive: a menu that opens, a form that checks your input, a chart that updates, or a game that runs in the browser. Almost every website uses it.
HTML, CSS and JavaScript
| Language | Job |
|---|---|
| HTML | Content and structure of the page |
| CSS | Design and layout |
| JavaScript | Behaviour: what happens when the visitor does something |
What can JavaScript do?
- Change the content and style of a page without reloading it.
- React to clicks, key presses, scrolling and form input.
- Check form data before it is sent.
- Load data from a server in the background (Fetch API).
- Build web apps, mobile apps and games.
- Run on a server with Node.js.
JavaScript is not Java
The names look similar, but the two languages are different, like “car” and “carpet”. Java is a different language used for Android apps and servers. JavaScript was named that way in 1995 only because Java was very popular at that time.
A short history
- Brendan Eich created JavaScript in 1995 for the Netscape browser, in about ten days.
- The language is standardised as ECMAScript (ES). ES6 (2015) added
let,const, arrow functions, classes and more. - A new ECMAScript version comes out every year, and modern browsers support it.
Your first line of JavaScript
console.log("Hello, JavaScript!");
Output of the above program is
Hello, JavaScript!
console.log() prints a message in the browser console. You will learn how to run it in the next chapters.
Summary
- JavaScript adds behaviour to web pages.
- It is different from Java.
- It runs in browsers and on servers with Node.js.
- Next: JavaScript Environment Setup.
Congratulations! Chapter Finished. Learn more about the similar topics:
| Exercises & Assignments |
|---|
| Write a JavaScript program to display Hello World |
| Interview Questions & Answers |
|---|
| What is JavaScript? |
| What is strict mode in JavaScript? |