Skip to main content

Getting started with Javascript (JS)

Getting started with Javascript (JS)


Hello everyone, and welcome to this amazing lesson on Javascript. If you are new to this platform, do check out our previous lessons. Here, we are going to begin studying some introductory concepts about JS and how they can be applied. This lesson is very essential for beginners who already know HTML and CSS and are willing to proceed with JS. Hence if you’re one, kindly go through the lesson till the end.

Javascript is a computer programming language used mainly for web development purposes. It was created by the Netscape browser in 1995, and it was a way for them to add action to their website. JS could be considered as a verb. That is, it enables actions like playing YouTube videos, signing up for a username, tweeting, posting, etc. It is lightweight and dynamic with object-oriented capabilities. Without Javascript on the web, we would have just HTML and CSS, making the web pages static, and only dynamic changes like animations from CSS will be left. 

Now that we know what Javascript is all about in a nutshell, let us look at what you can do with it. It is applicable in the following ways:

It is mainly used in the addition of interactive behaviour to web pages. Examples of such interactions could be the changing of the font color or button color when the mouse hovers over it, playing a video on a web page, displaying a timer on a site, and so on. There are many other things you can do with respect to this.

Various Javascript frameworks (Collections of Javascript code libraries that provide pre-written code) can be used in the creation of web and mobile apps. Some examples of Javascript frameworks are: React, React Native, Angular, and Vue for frontend.  A very solid example of a platform that uses JS is Instagram.

Javascript can also be used in the building of web servers and development of server applications. Do you love games? Here’s one fun fact. You can use Javascript to create browser games.

You will get to know more about Javascript as we proceed with our lessons, but before that, let us see how we can add javascript to a web page. 

There are two methods of adding JavaScript to a webpage;

  1. The first is by adding a script tag and typing the code within it.
    Getting started with Javascript (JS)

  2. And the second method is by adding an external Javascript code to the webpage.

For the first method, we will be embedding our javascript in the HTML code. To do that, type the following code in any code editor of your choice and save the file with the extension “.html”. After saving, you open the saved file (HTML file).

index.html

Getting started with Javascript (JS)
The above code produces the following output.

OUTPUT

The second method is by adding an external javascript code to the webpage. It can be done by typing the javascript code in any code editor of your choice and saving the file with the “.js” file extension.  After creating it, you then open your html code and you add the directory link to where the javascript file is saved on your computer. Let’s try to reproduce the above by using this second method.

Modify your HTML code at the level of the script tag to be like the one below.

According to the code above, our Javascript file name is script.js .Below is the code found in the JS file.

Getting started with Javascript (JS)
script.js

Getting started with Javascript (JS)
Observe the output of the second method :

Now we have come to the end of this lesson. I hope you learned something new today? Please subscribe to our youtube channel for more exciting tutorials. In the next lesson, we will be looking at Javascript variables. Thanks for your attention.


Comments

Popular posts from this blog

Introduction to flask

Hello. Welcome to another session on this platform. If you are new here, please do checkout our previous articles on python programming language and stay excited on this session because we are entering into one of python’s web-based application called flask. In this article, we are going to see the following What is flask Prequistes Installation of flask in python Some of flask template engine. What is flask? Flask is one of python-based framework which is used to create web applications. Flight is a very light web framework. During installation, flask comes with pre-installed modules and functions which are used to backup your own web applications. Flask is very easy to understand and perfect go-to for beginners and with flask, a web server can run in less than 3 lines of code. Prequistes Before learning flask, we recommend the reader to have a basic mastery of python concepts. Installation of flask  Before installing flask, we have to checked if python has been installed or. If n...

How to generate random numbers using NumP1

Hello. Welcome to another edition on this platform. For more better understanding, do checkout our YouTube channel to get the video tutorial. In this article of today, we are going to see how to generate random numbers using any of the following methods: Generating a random number Generating a random float and integer Generating random number arrays Generating random number from an array What is a random number? This is a number which cannot be predicted before its occurrence. This number might not different every time. Programmatically, they are two categories of random numbers:     Pseudo-Random numbers       True Random numbers. Just as programs which are written by programmers are a set of instructions, we must follow an algorithm to generate random numbers. Random numbers which are generated using an algorithm are called Pseudo-Random numbers. To generate a true random number, it is important to get the data from sources such as the keyboards, mou...

Introduction to Django

Hello. Welcome to another session on this platform. If you are new here, please do checkout our previous articles on python programming language and stay excited on this session. we are entering into one of python’s application called Django. In this article, we are going to discuss the following: What is Django Why must we use Django  A brief history of Django Installation of Django Popularity of Django What is Django? Python has so many framework application and Django happen to be one of them. Being a python-based-framework, it is used to quickly create web applications.  When building websites, django provides similar ready-made components to handle user authentication, forms, a way to upload components. Why use django? Django is very fast. It takes applications from concept to applications very quickly Django has thousand available packages in it when it is installed. With django, we can launch web applications is a matter of hours. Django is a highly is secured and helps...