In Javascript, we can use comments to annotate our code.
Comments are ignored by the Javascript interpreter and serve as notes for developers, making the code more readable and understandable.
Single-line comments start with // and extend to the end of the line.
They are useful for adding brief explanations or notes within your code.
// This is a single-line comment let variable = 123; // This is another single-line comment
Multi-line comments start with /* and end with */.
They are used for commenting out blocks of code or adding more extensive comments.
/* This is a multi-line comment It can span multiple lines Useful for commenting out entire blocks of code or providing detailed explanations */ let count = 11; let age = 12;
// Function to calculate the Multiple of two numbers function multiple(a, b) { return a * b; } /* This block of code initializes an array with some values. The forEach loop iterates through each element and logs it to the console. */ let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; numbers.forEach(function(num) { console.log( 2 * num); });
The syntax below will comment on the entire block of code and the javascript engine ignored during code execution.
function multiple(a, b) { return a * b; } /* function add(a, b) { return a + b; } function divide(a, b) { return a / b; } */
Code Documentation
Explaination of flow
Temporary Disabling Code
Todo and Notes
// Code Documentation: Function to calculate the multiple of two number function multiple(a, b) { return a * b; } // Explaination of flow: Check isStudent if (isStudent) { // Display Student dashboard } else { // Redirect to Faculty dashboard } /* Temporary Disabaling Code function add(a, b) { return a + b; } function divide(a, b) { return a / b; } */ // TODO: Implement Student Profile Details // NOTE: This Application Required Bootstrap CDN