What is JavaScript Syntax? This is 2nd Post

Hello friends, in today’s post, we are starting you about JavaScript(What is JavaScript Syntax), what happens. How does the key work, so today you should tell about JavaScript.

Javascript Syntax

It is very easy to add JavaScript to any HTML program, so that you can use the <script> tag in the program and you can add the <script> tag anywhere in the HTML program.

The <script> tag lets the browser know that JavaScript code is written and how to interpret it.

The <script> tag in JavaScript is defined by two attributes which are given below

* Language – By this attribute you can define scripting language like PHP and JavaScript etc.

* type – By this attribute it is necessary that with this you can also define the type of your file such as text / JavaScript etc.

With the help of these two attributes, you define the script tag with its help.

Let us try to understand it through an example

 Note:- If we want to use the code of JavaScript in any programming language other than the JavaScript file, then for this you can use <script> </script> , given in between these two tags.

JavaScript standard syntax is defined below

<script language=”javascript” type=”text/javascript”> // Here the code of JavaScript is written </script>

You can also define <script> tag by language attribute but it is mandatory to give type attribute.

How to print hello world using JavaScript?

If you want to print hello world through the program of JavaScript, then you are being given the program below.

<!DOSTYPE html>
<title>first javascript program</title>
<script type=”text/javascript”>
document.write(“hello world”);

In this code you can see that HTML has been printed by adding JavaScript to the file.

Note: – Remember that the extension of HTML is .htm or .htm. The extension of css is .css and the extension of JavaScript is your .js.

The <script> tag is written above the closing body tag, that is, your JavaScript code is placed above the closing body tag </body> tag.

Remember: – You can accept both double quotes (” “) or single quotes (‘ ‘) in JavaScript.

reference – https://www.w3schools.com/js/js_intro.asp

what is javascript syntax

Request – If you found this post useful for you(what is javascript syntax), then do not limit it to yourself(basic infomation of javascript), do share it

Leave a Comment