DEV Community

Chandra🟢
Chandra🟢

Posted on

What is JavaScript and writing “Hello world” Program in JavaScript.

First, I would like to welcome to you all in this article. If you are completely new to the JavaScript, you are in the right place.

What is JavaScript?

JavaScript is a programming language. JavaScript was created by Brendan Eich in 1995. Initially the purpose of this language was just to “make web pages alive”. But nowadays you can use this language to make server-side, Mobile, and desktop applications using various frameworks and libraries. To run the JavaScript code, we need a JavaScript engine. The browser has an embedded engine.

For example,

Chrome and Opera have a V8 engine,
Firefox has spiderMonkey.

These engines read the JavaScript code and then convert it to the machine language and run the machine codes.
We will go through what this language can do in the browser in the coming tutorials.

Writing the “Hello World” Program in JavaScript.
You need to have at least,

  1. A Web browser
  2. And an IDE(Notepad, visual Studio code.. ) to run the JavaScript code. The good thing is you don’t need to have the internet to run JavaScript code. There are many ways you can run the JavaScript codes.

1.Using “Script” Tag

You can insert javascript programs to any part of HTML document with the help of
<Script> tag.

For example,

<!DOCTYPE HTML>
<html>

<body>

  <p>Before the script...</p>

  <script>
    alert( 'Hello, world!' );
  </script>

  <p>...After the script.</p>

</body>

</html>

This code simply pup ups the message " Hello, world" in the browser.

Like this

Alt Text

2. Using external Scripts.

If we have a lot of code we can put code in the separate file. we need to put the .js extension at the end of the javascript file.

Script files are attached to HTML with the src attribute:

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

Here script.js means the javascript file name and 'src' is the attribute. which means get a script from source script.js.

You can have multiple script tag to attach multiple .js file.

Thank you so much for reading this article.

Best wishes to your Learning. If you have any confusion with this article you can comment on the comment box or send me a private message to cbshresthau22@gmail.com

References

*https://javascript.info/hello-world
*https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript

Top comments (0)