JavaScript Syntax & Commenting in Hindi :
किसी भी HTML Program में javaScript को add करना बहुत ही आसान होता है। इसके लिए आप <script> tag use कर सकते हैं। आप <script> tag को अपने Html Program में कहीं भी add कर सकते हैं।
लेकिन readablity के लिए हमेशा ये suggeste किया जाता है की आप इसे <head> tag के अंदर ही लिखे। <script> tags से browser को पता चल जाता है की ये JavaScript कोड है और इसे कैसे interpret करना है।

JavaScript Syntax & Commenting in Hindi
<script> tag के 2 attributes होते हैं। इन attributes के द्वारा आप scripting language और type define करते हैं।
- language - attribute से आप scripting language define करते हैं जैसे PHP और JavaScript आदि।
- Type -ये attribute necessary होता है इसे आप अपनी file का type define करते हैं , जैसे -की text /JavaScript .
इन attribute की मदद से आप <script> tag को define करते हैं। इसका उदाहरण नीचे दिया जा है।
<script language=”javascript” type=text/javascript”>
//यहां आप javascript
code लिखते हैं।
</script>
|
ये JavaScript defines करने का standard syntax है। आप चाहें तो language attribute के बिना भी <script> tag define कर सकते हैं। लेकिन type attribute add करना अनिवार्य है।
A very fast JavaScript Program
<html>
<head>
<title>first
javascript program</title>
</head>
<body>
<script type=”text/javascript”>
document.write(“Hello
sseffort! ”);
</script>
</body>
</html>
|
ऊपर दिए गए program में हमने एक html file कुछ JavaScript codd add किया है। ये एक बहुत ही simple program है। सबसे पहले <body> section में <script> tag define किया गया है। <script> tag में write function को call किया गया है। इस function में एक string pass की जाती है ये function उस string को web page पर show करता है। इसी तरह आप program में जहाँ भी javascript add करना चाहते हैं कर सकते हैं।
ऊपर दी गयी script नीचे दिया गया webpage generate करेगी।
![]() |
| JavaScript Syntax & Commenting in Hindi |
Adding Comments to a JavaScript Program:
Javascript में single line और multi-line 2 तरह के comments होते हैं। इनके बारे में नीचे दिया जा रहा है।Single-line comments :
Single line Comments आप double backslash(//) द्वारा add करते हैं। इसका उदाहरण निचे दिया जा रहा है।
<script
type=”text/javascript”>
//
this is a single line comment
Some
other JavaScript code here
</script>
|
Multi-line comments :
Multi-line comments में आप एक backslash और * add करते हैं। इसका उदाहरण निचे दिया जा रहा है।
<script
type=”text/javascript”>
/*
this is a single line comment */
Some
other JavaScript code here
</script>
|

0 Comments
Please do not enter any spam link in the comment box