javascript docs function code example

Example 1: javascript function description standards

/**
 * @name hash
 * @description Random hashing algorithm I found on Stack Overflow.
 * @param {string} str 
 * @param {boolean} asString 
 * @param {*} seed 
 * 
 * @returns {string} hash
 */
function hash(str, asString, seed) {

Example 2: documenting functions javascript

/**
 * Toggle visibility of a content tab
 * @param  {String} selector Selector for the element
 * @param  {Node}   toggle   The element that triggered the tab
 */
var toggleVisibility = function (selector, toggle) {
	if (!selector) return;
	var elem = document.querySelector(selector);
	if (!elem) return;
	elem.classList.add('active');
	if (toggle) {
		toggle.classList.add('active');
	}
	elem.focus()
	if (document.activeElement.matches(selector)) return;
	elem.setAttribute('tabindex', '-1');
	elem.focus();
};