Advertisement
Tech

Free Basic Lessons on JavaScript - An Introductory JavaScript Tutorial

In this tutorial, I will show you why JavaScript is important in web development and take you through the basics of how it works. This lesson also explains basic printing and arithmetic operations.

By Finn Orfano
Desk Tech
Reading time 2 min read
Word count 333
Web development Internet Javascript help
Free Basic Lessons on JavaScript - An Introductory JavaScript Tutorial
Advertisement
Quick Take

In this tutorial, I will show you why JavaScript is important in web development and take you through the basics of how it works. This lesson also explains basic printing and arithmetic operations.

On this page

JavaScript - Introduction

This lesson will guide you through the basics of JavaScript - the scripting language of the web. JavaScript is a scripting language which can be used to add interactivity to static HTML web pages. It is mainly used as a client side script language in conjunction with CSS in order to create dynamic web user interfaces. It is supported by all major browsers including Internet Explorer, Firefox, Opera, Safari, Webkit etc.

It is a very easy-to-learn language; the basics of which can be learned in a matter of minutes.

Advertisement
  • To insert JavaScript in an HTML web page, you must use the
    Advertisement

Here’s an example:

document.write(“We are learning JavaScript”);

Advertisement

Whenever the browser loads the page, it recognizes the tag.

Example:

Advertisement

var a = 10; / saving integer values in the variable

var b = 20;

Advertisement

var atext=“Pat was here”; / saving a string in a variable

To print variables directly,

Advertisement

document.write(a);document.write(atext);

Here is how you can use them:

Advertisement

var a = 10;var b = 20;

var add = a+b; / Adding variables a and b

Advertisement

var sub = a-b; / Subtracting variable b from a

var mul = a*b; / Multiplying variables a and b

Advertisement

var div = a/b; / Dividing variable a by b

Here is some code to demonstrate what we have learned so far:

Advertisement

Advertisement

To run this, copy this code to a text file and rename it to webpage.html. You can name it anything you want. To view the page, open you web browser. Go to File > Open and browse to the location of the web page and open it.

Note: Despite the similarities in name, JavaScript is completely different from Java.

Keep Exploring

More from Tech

Filed under
Web development Internet
More topics
Javascript help
Advertisement