JavaScript Introduction

JavaScript is the programming language of the web. It can update and change both HTML and CSS, and it can calculate, manipulate, and validate data.

What Can JavaScript Do?

CapabilityExample
Change HTML Contentdocument.getElementById("demo").innerHTML = "Hello"
Change HTML Styleselement.style.fontSize = "35px"
Change Attributeselement.src = "new-image.png"
Hide Elementselement.style.display = "none"
Show Elementselement.style.display = "block"

Change HTML Content

The most common use of JavaScript is to dynamically modify HTML content using innerHTML.

Example
// Change the text of an element
document.getElementById("demo").innerHTML = "Hello JavaScript!";
console.log("Element updated!");

Change HTML Styles (CSS)

Example
// Change font size dynamically
document.getElementById("demo").style.fontSize = "35px";
console.log("Style changed!");

A Bit of History

JavaScript was invented by Brendan Eich in 1995. It became an ECMA standard in 1997. ECMA-262 is the official standard name. ECMAScript is the official name of the language.

📝 Note: JavaScript and Java are completely different languages, both in concept and design.
Exercise:
What was JavaScript originally created for?
Try it YourselfCtrl+Enter to run
Click Run to see the output here.