Domanda

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

È stato utile?

Soluzione

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?

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top