@this
Syntax
@this {type}
Overview
@this clarifies what this refers to inside a function that is called in a context where it might not be obvious. It is particularly useful for standalone functions that are called with .call() or .apply(), or assigned as event handlers.
Examples
/**
* @this {HTMLElement}
*/
function onClick() {
this.classList.toggle('active');
}
button.addEventListener('click', onClick);
/**
* Formats the label using the instance's locale.
* @this {Formatter}
* @returns {string}
*/
function formatLabel() {
return this.locale.format(this.value);
}
See also
Official reference: jsdoc.app/tags-this