JavaScript Functions
JavaScript Functions - Important Points
1. | What is a JavaScript function? |
---|
A. A keyword used to define variables
B. A set of instructions that perform a specific task
C. A method used to create objects
D. An object that contains properties and methods
View Answer Discuss Work SpaceAnswer: option b
Explanation:
A JavaScript function is a set of instructions that perform a specific task. Functions can be reused and called multiple times in a program.
2. | What is the purpose of a function parameter? |
---|
A. To pass values into a function
B. To declare variables inside a function
C. To define a function's name
D. To specify a function's return value
View Answer Discuss Work SpaceAnswer: option a
Explanation:
3. | What is the difference between function declarations and function expressions in JavaScript? |
---|
A. Function declarations use the "function" keyword, while function expressions use the "=>" operator
B. Function declarations are hoisted, while function expressions are not hoisted
C. Function declarations must have a name, while function expressions do not require a name
D. Function declarations can be assigned to variables, while function expressions cannot be assigned to variables
View Answer Discuss Work SpaceAnswer: option b
Explanation:
4. | What is a callback function in JavaScript? |
---|
A. A function that returns another function
B. A function that takes another function as an argument
C. A function that is defined inside another function
D. A function that is used to create objects
View Answer Discuss Work SpaceAnswer: option b
Explanation:
5. | What is the purpose of the "return" statement in a JavaScript function? |
---|
A. To specify a function's input parameters
B. To declare variables inside a function
C. To specify a function's name
D. To return a value from a function
View Answer Discuss Work SpaceAnswer: option d
Explanation: