Home HTML CSS JAVASCRIPT BOOTSTRAP Python Docker ML tutorial About us Privacy policy

Comments


Comments

javaScript Comments are use to make our code more readale and easy to understand. Comments are not display on the browser,they are only Define our souce code in a different sections.

Single Line Comments


  • We can write single line comments in javaScript with //.
  • If you keep any code after // that code will not display on the browser.
  • Example:
    // change myHeading
     document.getElementById("heading").innerHTML="CodesFamily";
    
     //Change heading Text Color
     document.getElementById("heading").style.color="red";
    Example:
    var a=10; // Declare a variable a;
     var b=20;  // Declare a variable a;
    
     varc=a+b // Sum of two variables

    Multi Line Comments


  • In javaScript Multiline Comments starts with /* and end with */ always.
  • If you keep your code between /* code */ that code will not be execyued.
  • Example:
    /* This is my code and I want to 
    change my heading and it's c color.*/
    
     document.getElementById("heading").innerHTML="CodesFamily";
     document.getElementById("heading").style.color="red";


    More Topics