Last updated on March 10, 2023 by Ayaz Ali Shah
With comments, we can also prevent code to execute. In the below example, we commented on the commented line of code through the double forward slashes.
// Comment the code section //document.getElementById("sum").value = z;
In this example, both lines are commented and the browser will ignore these lines. There are two types of comments single-line comments and multiline comments.
The single line comments start with a double forward slash (//) after this code all of the words will be commented and the browser will ignore the line.
/* The below code will set the page title and subtitle */ document.getElementById("pageTitle").innerHTML = "Page Title"; document.getElementById("sub-title").innerHTML = "Sub Title";
In the above example we commented on the hint code which is starting with the forward-slash (/*) plus steric and then the content of the hint closes with the asteric and forward slash (*/) so all of the text between this will be ignored by the browsers.