Web Development — Level 2: JavaScript & Interactive Web Pages
Free preview

Your first JavaScript

1 / 3

What JavaScript does

  • HTML = structure, CSS = style, JS = behaviour
  • Runs in every browser
  • Also on servers (Node.js) and phones
2 / 3

Adding JS to a page

  • <script src="app.js" defer></script>
  • Put scripts at the end or use defer
  • Keep JS in separate files
3 / 3

The console

  • F12 → Console
  • console.log() to print values
  • Errors appear in red with the line number

Lecture notes

JavaScript is the programming language of the web. HTML describes the structure, CSS the presentation and JavaScript the behaviour: what happens when a user clicks, types or scrolls. It runs in every browser, and also on servers (Node.js) and in mobile apps.

Adding JavaScript to a page

<!-- at the end of <head>, with defer -->
<script src="app.js" defer></script>

The defer attribute downloads the script without blocking the page and runs it once the HTML is parsed, so your code can find every element. Keep JavaScript in separate .js files rather than inside HTML attributes.

The developer console

Press F12 (or right-click → Inspect) and open the Console tab. console.log("Hello") prints a value there; errors appear in red with the file name and line number — always read them first when something does not work.

Statements and comments

// a single-line comment
/* a comment
   on several lines */
console.log("Welcome to ACADEXXA");   // a statement ends with ;

JavaScript is case-sensitive: total and Total are two different names.

Want to go further?
18 h · Enroll to access every lesson and earn the certificate.
Get Started Free