JavaScript Study Material

What is JavaScript?

JavaScript is the programming language of the web. HTML gives a page its structure, CSS its look, and JavaScript its behaviour: responding to clicks, validating forms, loading data without reloading, animating, and much more.

  • It runs in every browser, with no installation.
  • With Node.js it also runs on servers, in command-line tools and build tools.
  • It is used for mobile apps (React Native), desktop apps (Electron) and even games.

Your First Program

Example

Press Run to execute this code in the code runner:

console.log("Hello, World!");
console.log(2 + 3);

Output

Hello, World!
5

JavaScript Can Change HTML

Example

In the browser, JavaScript can read and change the page. Click the button:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">Click Me!</button>

</body>
</html>

Result

JavaScript vs Java

Note: Despite the name, JavaScript and Java are completely different languages. The name was a marketing decision in 1995. The official standard is called ECMAScript; ES6 (2015) added most of the modern features you will learn here.