JavaScript Content

 

JavaScript unofficially is comprised of 2 parts. 

The language itself, or the 'Logic' core part, and a bunch of methods that deal with DOM manipulation (those are called Web API's). How to deal with HTML elements and CSS properties in other words.

The logic part is mandatory to learn in order to make the necessary calculations, transformations or alteration in terms of data, make decisions, execute code periodically and many more.

In order to print these results for debugging purposes, a developer normally uses browser's console.

Attention: The logic part is necessary to be mastered before proceeding to the presentation part, since the latter uses many, if not all the functionalities of the first part to do it's job.

Once the logic part is mastered instead of presenting the results to console and to ourselves we need to learn how to present them to the end user, by appending the result to the page.

This is done by the 'presentation' part or better the Web API's part.

How to connect JS with our HTML document?

 

There are 3 ways to include a JS script to your webpage. Inline, internal and external. Let's take a look at each,and see how.

1. Inline JavaScript. Include different javascript code for every html element. Highly inefficient and not recommended. Wasted performance. Direct connection though.

Take notice that you must have placed an external script to the head of your HTML file (see external js for that).