In general terms: what is the difference between a handler and a function?

From this answer ( What is a handler ) I understand that a handler:

A handler is a method / method / method that specializes in a particular type of data or focuses on specific special tasks.

But then I ask myself: why not replace the word handler with the word function? Who cares? The only difference I can say is that functions do not need to have arguments, which means that they do not need to focus on a particular data type. And some functions - without arguments - are not focused on specialized tasks.

But besides this, what is the difference between a handler and a function?

Some more background:

I find that the concept of a handler is hard to understand (maybe this is because I'm Dutch and it doesn't say a word in Dutch according to Google Translate). Verification of the definition helps a little, but not completely. enter image description here

+4
source share
4 answers

A handler is simply a more specific term. What is the difference between fruit and apple?

JS , . . "", . "", , - , , , Express .

+8

- . - , , , img .

+4

: -, , HANDLER, , .

Imagine the onclick event in html, it will call a function, this function will be a handler.

0
source

Handlers are functions that are called in response to some actions / events, whereas a function is what we call from our code.

In most cases, the handler receives an argument that describes which event triggered it.

This is usually just a function, but the reason it is called makes it different.

0
source

Source: https://habr.com/ru/post/1678248/


All Articles