JAVASCRIPT

Why it's important?

WHAT KIND OF LANGUAGE?

  • ECMAScript standard
  • Interpreted (and JIT Compiled)

WHERE IT RUNS?

Web Browser

Mobile Phone

Web Server

Desktop

HOW TO ADD JS CODE TO A WEB PAGE?

<!DOCTYPE html>
<html>
<head>
<script>
console.log("Hello!");
</script>
<script src="externalFile.js"></script>
</head>
<body>
<button onclick="console.log('Hi!')">Click Me!</button>
<script>
console.log("Hello again!");
</script>
</body>
</html>

WHEN THE CODE IS RUN?

<!DOCTYPE html>
<html>
<head>
<script>
console.log("Hello!");
</script>
<script src="externalFile.js"></script>
</head>
<body>
<button onclick="console.log('Hi!')">Click Me!</button>
<script>
console.log("Hello again!");
</script>
</body>
</html>

CODE COMMENTS

The text that is not run...

<script>
console.log(1);
// single line comment
console.log(2);
/* multi
line
comment */
console.log(3)
</script>

Who needs comments?

Document Object Model

How to draw a DOM tree?

An event listener

Let's see how to make one for a button..