Your Cart

Get Amazing Offers on Scripts

Get UX Support

JavaScript Complete Tutorial

In this section, you will learn how to learn JavaScript Quickly.

You may find it very difficult to understand advanced JavaScript code. These may happen mainly due to not understanding between JavaScript Predefined element and custom JavaScript element. Here we will try to solve these issues by letting you know which is a predefined JavaScript element or a custom JavaScript element.

Example Code

var brandNames = "Tutorialslides";
In above code left differentiate between the predefined JavaScript element and your custom element. brandNames & Tutorialslides are custom elements

Lets get started with basics of JavaScript and its History.

  • JavaScript was invented by Brendan Eich in 1995.
  • JavaScript is the world’s most popular programming language.
  • JavaScript is the programming language of the Web.
  • JavaScript is easy to learn.

How to Include JavaScript in an HTML Page?

To include JavaScript inside a page, you need to add it before  </head> or else we can add it before </body> tags:

Example Code

<script type="text/javascript">

//JavaScript code goes here

</script>

How to Include External JavaScript File?

We can create different types of scripts separate from one another, making for better-organized files. To create a javascript file, we need to use the .js extension. And we can also use custom name along with .js extension.

Example Code

<script src="my-custom-scripts.js"></script>

We can include multiple external JavaScript files.

Example Code

<script src="my-first-scripts.js"></script>

<script src="my-second-scripts.js"></script>

How to Include comments to the JavaScript code?

In JavaScript there are two types of  comments option are available.
1. Single-line comments//
2. Multi-line comments Starts with /*  and Ends with */.

Comments are very important as we can properly arrange our codes.
For example,
If multiple developers are working on a single project, a developer may not know who has created a JavaScript functionality. In this scenario, we can use Single-line comments.

If we want to disable a functionality without removing the code we can use Multi-line comments.

Example Code

//this is a Single-line comment

let x = "Total Pizza" + 10;

// Sample Developer Signature Single-line comment given below
//John Doe last updated on 06/11/2021 

/*this is a 
Multi-line comment */

let x = 10 + "Pizza Sold";
document.getElementById("pizza").innerHTML = x;

/* You can easily comment above given code like this
let x = 10 + "Pizza Sold";
document.getElementById("pizza").innerHTML = x;

*/

Variables

There are 3 ways to declare a JavaScript variable:
1. Using var
2. Using const
3. Using let

var  – Variables are containers for storing data. If you re-declare a JavaScript variable, it will not lose its value.

const  –  Variables must be assigned a value when they are declared. Always declare a variable with const unless you know that the value will change.

let  –  Variables defined with let cannot be redeclared.
You cannot accidentally redeclare a variable. Variables defined with let must be Declared before use. Variables defined with let have Block Scope.

Example Code

//this is a Single-line comment

let x = "Total Pizza" + 10;

// Sample Developer Signature Single-line comment given below
//John Doe last updated on 06/11/2021 

/*this is a 
Multi-line comment */

let x = 10 + "Pizza Sold";
document.getElementById("pizza").innerHTML = x;

/* You can easily comment above given code like this
let x = 10 + "Pizza Sold";
document.getElementById("pizza").innerHTML = x;

*/
Fast Download

Instant access to your digital products right after purchase.

Custom Softwares

Completely build by Tutorialslides

Latest Sofware Updates

Offered in the country of usage

100% Secure Checkout

PayPal / MasterCard / Visa