'Commenting "null" value in javascript
What is the right way to comment null value in javascript? For example:
/**
* Hides an element.
* @param {String} id - element id (can be {@code null}).
* @returns {undefined}.
*/
function hide(id) {
if (id !== null) {
document.getElementById(id).style.visibility = 'hidden';
}
}
But the tag {@code null} not working...
Solution 1:[1]
Just came across the same issue myself and found that using backticks (``) did the trick for me. Using the JSDoc comment used in your example, it should look like:
/**
* Hides an element.
* @param {String} id - element id (can be `null`).
* @returns {undefined}.
*/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeff G |
