JavaScript Where To

The <script> Tag:

The JavaScript code is placed between the <script> and </script> tags.

Example:

.lang-js
<script>

document.getElementById("demo").innerHTML = "Introduction to JavaScript";

</script>

JavaScript Functions and Events

A JavaScript function is a chunk of JavaScript code that runs when you call it.

You can position the JavaScript functions in the <head> and <body> of the HTML documents. JavaScript can also be placed in external files with extension with .js.