DEV Community

TutsCoder
TutsCoder

Posted on • Originally published at tutscoder.com

Learn JavaScript from Scratch

In this post, we will learn the basics of the JavaScript programming language. 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.

What is Javascript?

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.

One thing always remembers Javascript must be written between starting and ending tag.

Let’s start.

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

Example:

<head>
    <title>Javascript Step by step</title>
    <script>
       //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');

    </script>

</head>
</html>

 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:

Example:

<html>
<head>
<script>
        function sampleFunction(){
            var name = prompt('Please Enter Your Name:', 'Name');

            document.write('Hello' + 'name' + 'To my website');
        }
    </script>
</head>

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

 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.

Conclusion:
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

Top comments (0)