JavaScript hooks allow custom code to be executed when some defined action (such as saving a page or a user logging in) is performed.JavaScript hooks are placed in various parts of MediaWiki core/extension/skin front end code, and can be used by other parts of MediaWiki core/extensions/skins,user scripts, andgadgets.
hook( 'name' ).add( yourFunction ) - will add your callback function to that hook. Then whenever the .fire() code is called, your function will be executed.hook( 'name' ).fire() - will create a new hook.