Course Hero Logo
This textbook is available Logo
JavaScript: The Web Warrior Series 6th Edition

JavaScript: The Web Warrior Series (6th Edition)

Book Edition6th Edition
SubjectComputer Science
Chapter 2, Working with Functions, Short Quiz, Exercise 1
Page 91

What is the difference between a named function and an anonymous function?


The differences between the named and anonymous function are given below. 

Named FunctionAnonymous Function
The named function is assigned with a name.The anonymous function is a function with no name.
Named functions can be invoked from multiple places within the program.Anonymous functions can be used only in the place where it is written. It cannot be accessed from elsewhere within the program.

The syntax of a named function is given below.                                                                                  

function function_name(arguments) 



The syntax of an anonymous function is given below.

function (arguments)




Sample Response

A named function can be used in multiple contexts whereas an anonymous function cannot be used.

How would you rate this answer and explanation?
Did you like this example?
Subscribe for full access
Page 91