1

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

10
  • 1
    Why would you need to tell people without knowledge what anonymous functions are? Just tell them you do shit with computer and call it the day. Commented Apr 3, 2014 at 18:22
  • anonymous functions are just regular functions without a name Commented Apr 3, 2014 at 18:23
  • 2
    I don't know but I think that parameter is more basic knowledge than an annon func... Commented Apr 3, 2014 at 18:24
  • 1
    What analogy did you use to explain a named function? Commented Apr 3, 2014 at 18:24
  • 3
    Anonymous function are like one night stands. Once the work is done, you will never hear of them again. If they are not a 1 night stand, you will still be able to call them. Oh wait, you're 13... That may not be the best analogy... Commented Apr 3, 2014 at 18:34

2 Answers 2

4

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?

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments