JavaScript Functions
JavaScript Functions - Important Points
11. | What is the purpose of the "this" keyword in a JavaScript function? |
---|
A. To refer to the function itself
B. To refer to the global object
C. To refer to the object that the function is a method of
D. To refer to the previous function in the call stack
View Answer Discuss Work SpaceAnswer: option c
Explanation:
12. | Which keyword is used to define a JavaScript function that can be called without creating an instance of the object? |
---|
A. static
B. prototype
C. class
D. function
View Answer Discuss Work SpaceAnswer: option d
Explanation:
13. | What is the purpose of the "new" keyword in JavaScript? |
---|
A. To create a new variable
B. To create a new object instance
C. To declare a new function
D. To import a module
View Answer Discuss Work SpaceAnswer: option b
Explanation:
14. | What is the output of the following code snippet? function myFunction(x, y) { |
---|
A. 5
B. 9
C. 11
D. Error
View Answer Discuss Work SpaceAnswer: option a
Explanation:
15. | What is the purpose of the "apply" method in JavaScript? |
---|
A. To call a 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 create a new object with a specified prototype object and properties
D. To bind a function to a specific "this" value
View Answer Discuss Work SpaceAnswer: option a
Explanation: