Skip to content

6. Javascript Comments in Hindi

    Javascript Comments in Hindi

    Introduction of Javascript Comments in Hindi

    इस लेख मे हम Javascript comments के बारे मे जानेंगे। Javascript मे कई बार code की length ज्यादा हो जाती है तब code को समझना मुश्किल हो जाता है। इसलिए code को readable बनाने के लिए comments का इस्तेमाल किया जाता है।

    यहा comments को Program के source code से साथ कोई लेना देना नहीं है। javascript comments को executes भी नहीं किया जा सकता है।

    Javascript comments का इस्तेमाल code को अधिक readable बनाने के लिए किया जा सकता है। Comments दो प्रकार के होते है।

    1. Single line Comments
    2. Multi line Comments

    Single Line Comments in Hindi

    Single line Comments // start होता है। और Javascript code पूरी line को ignore कर देता है।

    उदाहरण

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

    आप code को समझने के लिए भी Comments का इस्तेमाल कर सकते हो।

    उदाहरण

    <!DOCTYPE html>
    <html>
    <body>
    <h2>JavaScript Comments</h2>
    <p id="one"></p>
    <script>
    var x = 5;    // Declare x, give it the value of 5
    var y = 2;  // Declare y, give it the value of 2 
    document.getElementById("one").innerHTML = x + y;
    </script>
    
    </body>
    </html>
    

    Multi-line Comments in Hindi

    Multi-line Comments /* से start होता है और */ से end होता है।

    /* और */ इसके बीच के text को Javascript ignore कर देता है।

    उदाहरण

    <html>
    <body>
    <script>  
    /* It is multi line comment.  
    It will not be displayed */ 
    document.write("Javascript Comments in Hindi");  
    </script> 
    </body>
    </html>
    

    Comment का इस्तेमाल आप Execution को रोकने के लिये कर सकते हो।

    अगर आप किसी code को execute नहीं करवाना चाहते तो उसके आगे // लगाकर उस code को disable कर सकते है।

    उदाहरण

    ;<html>
    <body>
    <h2>Javascript Comments in Hindi</h2>
    <h1 id="one"></h1>
    <p id="two"></p>
    <script>
    //document.getElementById("one").innerHTML = "Heading";
    document.getElementById("two").innerHTML = "paragraph.";
    </script>
    
    </body>
    </html>
    

    Next : Javascript Variables in Hindi

    Leave a Reply

    Your email address will not be published. Required fields are marked *