Frage

What is an analogy used to explain anonymous functions in javascript to a layman person? I am a 13 year old coder trying to explain anonymous functions to people without knowledge of coding how can I explain anonymous functions without using any big words like parameters or curly braces

War es hilfreich?

Lösung

Anonymous functions are just functions without names. Functions are things that actually do something (they perform a job).

So the analogy could be that there are people that do jobs at a store. Regular functions are people that do their job while wearing a name tag. Anonymous functions are the guys who work at a store that don't have name tags.

Does that make sense?

Andere Tipps

Anonymous functions are functions that are dynamically declared at runtime. They’re called anonymous functions because they aren’t given a name in the same way as normal functions.

Anonymous functions are declared using the function operator instead of the function declaration. You can use the function operator to create a new function wherever it’s valid to put an expression. For example you could declare a new function as a parameter to a function call or to assign a property of another object.

Here’s a typical example of a named function:

function flyToTheMoon()
{
  alert("Zoom! Zoom! Zoom!");
}
flyToTheMoon();

Refer - Link

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top