JavaScript Functions
JavaScript Functions - Important Points
21. | What is the difference between a named function and an anonymous function in JavaScript? |
---|
A. Named functions can be called from anywhere in the code, while anonymous functions cannot be called
B. Anonymous functions are defined without a name, while named functions have a name
C. Named functions are hoisted, while anonymous functions are not hoisted
D. Anonymous functions can be assigned to variables, while named functions cannot be assigned to variables
View Answer Discuss Work SpaceAnswer: option b
Explanation:
22. | What is the purpose of the "arguments" object in a JavaScript function? |
---|
A. To specify a function's input parameters
B. To store a function's local variables
C. To create a new array of arguments passed to a function
D. To access all arguments passed to a function as an array-like object
View Answer Discuss Work SpaceAnswer: option d
Explanation:
23. | What is a closure in JavaScript? |
---|
A. A function that takes another function as an argument
B. A function that returns another function
C. A function that accesses variables outside its own scope
D. A function that is used to create objects
View Answer Discuss Work SpaceAnswer: option c
Explanation:
24. | What is a higher-order function in JavaScript? |
---|
A. A function that takes another function as an argument
B. A function that returns another function
C. A function that accesses variables outside its own scope
D. A function that is used to create objects
View Answer Discuss Work SpaceAnswer: option a
Explanation:
25. | What is the purpose of the "apply" and "call" methods in JavaScript? |
---|
A. To create a new function with a specified "this" value and arguments provided as an array
B. To call a function with a specified "this" value and arguments provided as individual arguments
C. To bind a function to a specific "this" value
D. To create a new object with a specified prototype object and properties
View Answer Discuss Work SpaceAnswer: option b
Explanation: