Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Javascript Tags

JavaScript
<script type="text/javascript">
	document.write("Hello DevOpSchool");  
</script>
<script src="devops.js" type="text/javascript"></script>

<script> Opening Script Tag.

src It’s an attribute of the script.

name.js – This is our script file, which we created. The code of javascript is written inside devops.js.
In which DevOps is the file name, .js is the extension. Javascript has an extension of .js

Type – This is also an attribute of the script tag, it tells the browser that it is javascript. Now it is not necessary to write it, you can leave it if you want.

Text/javascript – It defines what type these documents are.

document.write(“Hello World”); – This is a function which is displaying the data.

</script> – Closing Script tag.

How to link more than one External?

You can link more than one JavaScript file to a single document. Just need to write different script tags for that.

&lt;script src="devops1.js" type="text/javascript">&lt;/script>
&lt;script src="devops2.js" type="text/javascript">&lt;/script>
&lt;script src="devops2.js" type="text/javascript">&lt;/script>
&lt;script src="devops3.js" type="text/javascript">&lt;/script>

How to use inline and External together in javascript?

No, both cannot be written together. But both inline and external can be written separately.

&lt;!DOCTYPR>
&lt;HTML>
    &lt;head>&lt;title>&lt;/title>
        
            
        &lt;/script>
    &lt;/head>
    &lt;body>
        &lt;h1>I am Heading&lt;/h1>
        &lt;p>I am Paragharph&lt;/p>
        
        &lt;script type="text/javascript">
			document.write("Hello Vijay");  
		&lt;/script>
        &lt;br>
        
        &lt;script src="devops.js" type="text/javascript">&lt;/script>
        
    &lt;/body>
&lt;/html>

Write funtion

This function is used to write arbitrary HTML and content into the page. If we use this function after an HTML document is fully loaded, will delete all existing HTML. It is used only for testing purposes.

Ex:-    document.write("Hello world");
	    document.write(variable);
	    document.write(4+2);
	    document.write("hello world . &lt;br>");
	    document.write("hello world . &lt;br>" + variable +"&lt;br>");

Alert function in JavaScript

The data that will be displayed in it will be in the dialog box. You forcefully want to see this thing, then only this work will be done. In that case, you use a window. alert

Ex:- window.alert("Hello World");
	 window.alert(variable);
	 window.alert(4+2);
	 window.alert("hello world"+ variable);
&lt;html>
	&lt;head>&lt;title>Hello JS&lt;/title>
		&lt;script>
			window.alert("Hello");
		&lt;/script>
	&lt;/head>
	&lt;/body>
`		&lt;h1>I am heading&lt;/h1>
		&lt;p>I am Paraghraph&lt;/p>
		
		&lt;script src="name.js" type="text/javascript">
		&lt;/script>
	&lt;/body>
&lt;/html>

Identifier

An identifier is a name having a few letters, numbers, and special characters _(underscore). It is used to identify a variable, function, symbolic constants, and so on.

Ex:- X2
PI
Sigma
Matadd

Veriable in JavaScript

Variable can be any name, in which a combination of letters, numbers, and special characters can be written _()(underscore) and $(dollar). It is not necessary that there should be only a combination, it can only be a letter.

Ex:- c, fact, b33, total_amount ect.

Rules of Veriable in JavaScript

  • Variable can contain a combination of letters, digits, _()(underscore), and dollar signs($).
  • Must begin with a letter A-Z or a-z or underscore or dollar sign.
  • A variable name cannot start a number.
  • Must not contain any space characters.
  • JavaScript is case-sensitive
  • Can’t use reserved keywords.

Reserved Keyword in javascript

Keyword or Reserved words

vardeleteforletbrack
supervoidcasedostatic
functionnewswitchwhileinterface
catchelseifpackagefinally
thiswithclassenumdefault
implementsprivatethrowtiledtypeof
constexportimportprotectedreturn
truecontinueextendsin
instanceof
publictrydebuggerfalse
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x