JavaScript - Comments in Hindi




दोस्तों इस chapter में हम JavaScript comments के बारे में जानेंगे तो चलिए शुरू करते है. JavaScript में कभी कभी हम इतना बड़ा कोड लिख देते है जो हम को समझ में नहीं आता है तो उस कोड को समझने के लिए हम comments में लिख सकते है और उसको more readable बनना के लिए भी JavaScript comments लिख सकते है।

Comments को आप simple language में लिखें गए notes भी कह सकते हों. इनका उपयोग किसी भी program के अंग को समझाने के लिए किया जाता है. Friends आपको पता होना चाहिये Comments का JavaScript के Code पर कोई effect नहीं पड़ता है. इसका मतलब यह हुआ आप comments के अंदर जो भी कोड या content लिखोगे उसका program के source code से कोई लेना-देना नहीं होगा है।

JavaScript comments किसी भी lesson की एक line होती है जिसे executed नहीं किया जा सकता. आप JavaScript कोड की व्याख्या करने के लिए JavaScript में comment का उपयोग कोड को अधिक पढ़ने योग्य बनाने के लिए कर सकते हैं JavaScript में दो प्रकार के comments होते हैं −

  • Single Line Comments

  • Multi-line comments

JavaScript Single Line Comments

Single Line Comments को double forward स्लैश (//) द्वारा display किया जाता है. इसका उपयोग statement से पहले और बाद में किया जा सकता है. आइए अब हम देखतें हैं कैसे single line comment work करता है।

Example

<html>
<body>
<script>  
// It is single line comment  
document.write("Hello My javascript");  
</script> 
</body>
</html>

Result

JavaScript Multi-line Comments

Multi-line Comments को single forward स्लैश (/) द्वारा display किया जाता है. यह हर lesson में / * के साथ शुरू होता है और * / से समाप्त होता है, / * और * / इस के बीच किसी भी content को JavaScript द्वारा अनदेखा कर दिया जाएगा. आइये अब हम Multi-line Comments एक उदाहरण देखतें हैं।

Example

<html>
<body>
<script>  
/* It is multi line comment.  
It will not be displayed */  
document.write("This is the example of javascript multiline comment");  
</script>  
</body>
</html>

Result