javascript function comments code example

Example 1: javascript comment

//This is a javascript single line comment

/*
And here is a
multiline comment
*/

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();
};

Example 3: how to comment in javascript

/* this is a javascript comment
that is multi lines */
// This is a single line comment

Example 4: js comment

//This does not effect the code.
var something = "But this does effect the code!";

Example 5: comment in JavaScript

// This is how you comment a single line in JavaScript

/*
This is how you comment
multiple lines in 
JavaScript
*/

Example 6: javascript comment

// For single line comment

/* For block of lines comment
...
...
*/

Tags:

Css Example