What is JavaScript?

Malcolm

Administrator
Administrator
Jan 2, 2018
1,015
277
95
Canada
codeforum.org
What is JavaScript?
JavaScript is exactly what the name says; it’s a script that controls the behaviour of a website. It helps make your website more interactable and there is no need for any special IDE platforms, you can create it using a regular text editor. In this thread, you will be given a quick understanding on how JavaScript works with HTML+CSS, add JavaScript (JS) within your HTML document, and how to link it externally to a .JS file.

How does JavaScript work with HTML+CSS?
Similar to both HTML and CSS, JavaScript has its purpose. In other threads, I explained what both HTML and CSS were and their purpose. Just a refresher: HTML is the structure of a webpage and CSS is used to style the appearance of the webpage.
Now, what does JavaScript do? JavaScript makes your basic HTML/CSS document or webpage more interactive. It can be used to update content, animate images, control multimedia, display prompts etc. It can give the viewer warnings stating that their password does not meet requirements, or give a specific message like good morning or good afternoon. JavaScript can make your site do a lot of great things, you just need to conquer it. Remember JavaScript is a scripting language so you set a set of instructions and the browser will execute them.

Adding JavaScript within your HTML Document:
Although not particularly recommended, you can add JavaScript within your HTML document by using the <script></script> tag. An example is below:
HTML: Internal JavaScript:
<!DOCTYPE html>
    <head></head>
    <body>
    <h1>Hello World!</h1>
        <script>
            document.write(‘Hello World!’); // Will print off “Hello World!”
        </script>
    <body>
</html>
Adding JavaScript with an external document:
A more practical way of adding JavaScript to your website is by creating a separate JavaScript file and linking it to your HTML document. Similar to the way of including an external CSS file. You can identify a JavaScript file by looking for the file extension .js.​
Within your HTML document under the <head> tag:​
HTML: External JavaScript:
<head>
    <script src=”js/javascript.js”></script>
</head>
The src attribute is the file path to your .js file.

Helpful sources:
JavaScript & Jquery by Jon Duckett
 
Last edited:
  • Like
Reactions: Mandiux
D

Dan-Kode

Guest
Just to add as a Note, JavaScript is not Java. They are both completely different Languages for completely different Tasks.

JavaScript is used for Websites, adding Functionality to them and making them more Dynamic.

Java on the other hand is used for Banks, Software and Android Apps.

Always remember that both Languages are completely different in terms of Functionality, Tasks and Syntax, despite the Name.
 
  • Like
Reactions: Mandiux and Malcolm

Malcolm

Administrator
Administrator
Jan 2, 2018
1,015
277
95
Canada
codeforum.org
Just to add as a Note, JavaScript is not Java. They are both completely different Languages for completely different Tasks.

JavaScript is used for Websites, adding Functionality to them and making them more Dynamic.

Java on the other hand is used for Banks, Software and Android Apps.

Always remember that both Languages are completely different in terms of Functionality, Tasks and Syntax, despite the Name.
Thanks for pointing this out! :)
 
  • Like
Reactions: Dan-Kode
D

Dan-Kode

Guest
Your welcome.

Some people do mistake JavaScript for Java and Java for JavaScript. Again, they're not the same.