Posted in All Posts, Semester 2

Introduction to JavaScript

JavaScript is designed to add interactivity to HTML pages, and is embedded directly to HTML pages. JavaScript is the most popular scripting language on the internet. It works in all major browsers such as Firefox, Chrome (my favourite!), Opera, Internet Explorer, etc.

It’s important to understand the difference between Java and JavaScript, Java is a full programming language with formal structures etc. while JavaScript is a scripting language developed to modify web pages.

JavaScript must be written between <script> tag in a HTML document.
As it is a scripting language, the code is not compiled, instead it appears as ASCII text in HTML file. JavaScript can be integrated in a HTML document in 3 ways
1. Integrating under the <head> tag.
2. Integrating under the <body> tag.
3. Importing the external JavaScript.

¤ Under <head> tag

When JavaScript is integrated under the <head> tag, it will be executed immediately while the page loads into the browser.

Try It Yourself

¤ Under <body> tag

When JavaScript is integrated under the <body> tag, it will be executed when the page loads into the browser and goes into the body section.

Try It Yourself

¤ Importing external JavaScript

You can import an external JavaScript file when you want the same JavaScript code to run on several HTML files.
An external JavaScript has to be saved with a .js file extension. The external JavaScript file can’t contain the <script> tag.

Try It Yourself

This was a short introduction to JavaScript. We’ll dive deeper into JavaScript in upcoming posts.

We hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.

If you liked this article, then please like our Facebook page.

Suggested Reading

9 thoughts on “Introduction to JavaScript

          1. you got to launch editor. on the right you will find JS references like angular, bootstrap, jquery etc.. if you want to work on pure javascrip, on the left you have an external JS file .. create functions, call it from html page and see the preview live .. you have a live preview icon at extreme right which refreshes every second..

  1. Good intro….right now I am struggling on whether to focus on Front-End development (HTML, CSS, and JavaScript) or Java. I understand that they are for completely different purposes. I kind of went ahead with learning both concurrently, we’ll see if I’ll regret this decision in the near future. Anyone out there know both are currently learning both that want to chime in?

Comment your thoughts