Learn JavaScript from Scratch : The Ultimate Beginners Guide

Learn JavaScript from Scratch : The Ultimate Beginners Guide

In this post, we will learn JavaScript from the basics. Today JavaScript has become one of the most popular programming languages on the web and the good part of JavaScript is easy to learn.

In this tutorial, I will teach you some basics of javascript.

Learn JavaScript from Scratch

What is JavaScript?

A Programming language that is used to make web pages interactive.

JavaScript is an easy and lightweight programming language of HTML and web. It is open-source and cross-platform.

What Can I do with JavaScript?

  • To make Responsive webpages. 
  • Put content in an HTML page on the fly. 
  • Validate forms. 
  • Create Animations, Slideshows, Scrollers, etc

In this tutorial, I will teach the basic functionality of javascript to build dynamic web pages and web applications.

Read, 8 Most useful Jquery Selectors - You Need To Know

How to add JavaScript in HTML?


Include JS in an HTML page, you’ll need to wrap the code in <script> tags, like this:

<script type="text/javascript">

//Your JavaScript code goes here



When you have large code collection, then its better to create separate JavaScript file and put all logic there to make code more efficiency and then link to it in your HTML file. 

So if your file is named script.js, then here’s how to call it in your HTML file.

<script src="/script.js"></script>

How to do Comments in JavaScript?

In Programming, Comments are very useful because they help other people to understand and can help to debug your code when it’s needed.

There are two different ways to add comments to your JavaScript code:

Single-line comments:

Using the “//”(Double slash) to add single-line comments to your code.

// Single line comment in JS
let myVar= "Some Value"

Multi-line comments:

You can write  multi-line comments in your code by Wrapping your comments in /* and */ as the start and finish of your comment, like this:

 Multi line comment in JS

Let’s start, with a basic example,

In the following example, we will make simple popup box using Javascript.


    <title>Javascript Step by step</title>
       //In name variable we will store value recived by popupbox
        var name =prompt('Please Enter Your Name:','Name');
        //now it print the value on browser in text format
        document.write('Hello'+' '+name+' '+'To my website');



 so, in the above example, we created a simple popup box that receives value from the user and displays it on the browser in text format.

This is the basic example of javascript uses.

Now we will learn how to create functions in javascript.

How to Create Function In JavaScript?

Functions are a Very useful term of any programming language. It is the collection of code and it makes our code dynamic and reusable. so let’s start making the function in javascript by the following example:


        function sampleFunction(){
            var name = prompt('Please Enter Your Name:', 'Name');

            document.write('Hello' + 'name' + 'To my website');

<input type="button" value="Sample Function" />

 In the above example, we have created a function named ‘sampleFunction’ and called on the click event of the button. So when the user will click on the button a popup will open and ask for a name and display on the browser. So isn’t simple.

Also read, 12 Most Helpful jQuery Methods and Functions


Do let me know If you face any difficulties please feel free to comment below we love to help you.if you have any feedback suggestion then please inform us by commenting.

Don’t forget to share this tutorial with your friends on Facebook and Twitter

Subscribe to our Newsletter

Stay up to date! Get all the latest posts delivered straight to your inbox.

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Leave a Comment