Running JavaScript

R

As you are reading this blog on online its pretty much sure that you have the full environment to run your JavaScript code right NOW!! How??

Your browser is the environment that is the only thing you need to run JavaScript code. Just press F12, then click Console. Here write a simple code

alert(”WoW”)

Press enter and you will see a alert box. Running JS code is that much easy ๐Ÿ˜€

The next thing is selecting a editor for writing code. There are plenty of editors like Sublime Text, Atom, Bracket, WebStorm, Visual Studio Code. Now a days I use VS Code a lot and also recommend it.

I will use VS Code for further tutorials. When installing VS Code click all four checkboxes it makes easy to openย  folder directly on editor.

Now, create a folder such as “learnjs” and right click on it and open with VS Code.

After opening folder now firstly we create a html page “index.html” and then add JS code named “app.js” file into it.

Open index page press ! then TAB, it will create a basic layout. Here in body section write the following code.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        console.log('I am Learning JavaScript');    
    </script>
</body>
</html>

 

Run the index page by double clicking it. press F12 and in in console menu you will see the result.

At this point you are ready to explore the next things but one last thing I want to show is writing JS in another file (app.js) and linking that file to index.html. The code is given below

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script src="app.js"></script>
</body>
</html>

 

app.js

console.log('I am Learning JavaScript');    

 

Happy Learning ๐Ÿ˜€

About the author

Imran Pollob

Learn => Practice => Implement => Repeat

Add comment

Categories

Imran Pollob

Learn => Practice => Implement => Repeat

Get in touch