Web Designing MCQs

20+ Multiple-Choice Questions On JavaScript Functions

Pinterest LinkedIn Tumblr Reddit WhatsApp
This set of multiple-choice questions on JavaScript functions includes MCQ on JavaScript function definition, nested function, and different ways of invoking functions. It also includes about closures and their implementation, function properties, methods, constructor, callable objects, different ways of processing arrays with functions, higher-order functions, and partial applications of functions. 

1. JavaScript functions can be invoked in which of the following ways.
i) as functions   ii) as methods   iii) as constructors
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii

2. Functions are invoked as functions or as methods with an …………….
A) invocation statement
B) invocation expression
C) invocation function
D) invocation method

3. An ……………… consists of a function expression that evaluates to a function object followed by an open parenthesis, a comma-separated list of zero or more argument expressions, and a close parenthesis. 
A) invocation statement
B) invocation expression
C) invocation function
D) invocation method

4. If a function or method invocation preceded by the keyword new, then it is a ……………
A) constructor invocation
B) new invocation
C) indirect invocation
D) direct invocation

5. In ………………. you can invoke any function as a method of any object, even if it is not actually a method of that object.
A) constructor invocation
B) new invocation
C) indirect invocation
D) direct invocation

6. Both call( ) and apply( ) methods allow you to explicitly specify the …………….. value for the invocation.
A) this
B) me
C) that
D) new

7. The function that can accept any number of arguments is called …………
i) variadic function   ii) variable arity function   iii) varargs function
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii

8. ………………. functions need not allow invocations with zero arguments.
A) zero
B) varargs
C) empty
D) strict

9. ……………. property is non-standard but commonly implemented property that refers to the function that called is one.
A) caller
B) callee
C) called
D) calling

10. The …………….. property is occasionally useful to allow unnamed functions to call themselves recursively.
A) caller
B) callee
C) called
D) calling

11. State whether the following statements are True or False about JavaScript function.
i) The function can be assigned to another variable
ii) Functions can also be assigned to object properties rather than variables
iii) Function require names at all
A) i-True, ii-False, iii-False
B) i-True, ii-True, iii-False
C) i-False, ii-False, iii-True
D) i-False, ii-True, iii-True

12. The combination of a function object and a scope in which the function’s variables are resolved in called a ………………..
A) coordinator
B) joiner
C) closure
D) resolver

13. The ……………. property of a function is a read-only property that returns the number of parameters it declares in its parameter list.
A) length
B) number
C) parameter
D) width

14. The ……………….. specifies usually the number of arguments that the function expects.
A) argument.number
B) argument.length
C) argument.parameter
D) argument.width

15. When a function is used as a constructor, the newly created object inherits properties from the ………….. object.
A) length
B) prototype
C) constructor
D) collable

16. Any arguments to ……………….. after the first invocation context argument are the values that are passed to the function that is invoked.
A) apply( )
B) call( )
C) bind( )
D) string( )

17. The argument to both call( ) and apply( ) method is the object on which the function is to be invoked.
A) first
B) second
C) third
D) none of the above

18. The …………… method is like the call( ) method, except that the arguments to be passed to the function are specified as an array.
A) apply( )
B) call( )
C) bind( )
D) string( )

19. If a function is defined to accept an arbitrary number of arguments, the …………… method allows you to invoke that function on the contents of an array of arbitrary length.
A) apply( )
B) call( )
C) bind( )
D) string( )

20. When you invoke the …………… method on a function f and pass an object o,  the method returns a new function.
A) apply( )
B) call( )
C) bind( )
D) string( )

21. ………………… is a common technique in functional programming and is sometimes called currying.
A) full application
B) partial application
C) common application
D) technical application

22. State whether the following statements about the function constructor are True or False.
i) The function( ) constructor allows JavaScript functions to be dynamically created and compiled at runtime.
ii) The function( ) constructor parses the function body and creates a new function object each time it is called.
A) True, False
B) False, True
C) True, True
D) False, False

23. A ……………. is any object that can be invoked in a function invocation expression.
A) caller object
B) callee object
C) callable object
D) calling object

24. A …………………. is a function that operates on functions, taking one or more functions as arguments, and returning a new function.
A) multiple order function
B) higher-order function
C) lower order function
D) new order function

Answers

1. D) All i, ii and iii
2. B) invocation expression
3. B) invocation expression
4. A) constructor invocation
5. C) indirect invocation 
6. A) this
7. D) All i, ii and iii
8. B) varargs
9. A) caller
10. B) callee
11. B) i-True, ii-True, iii-False
12. C) closure

13. A) length
14. B) argument.length
15. B) prototype
16. B) call( )
17. A) first
18. A) apply( )
19. A) apply( )
20. C) bind( )
21. B) partial application
22. C) True, True
23. C) callable object
24. B) higher-order function

Read Next: Top 20 Multiple-Choice Questions on JavaScript Arrays

Read More:

Please follow and like us:
RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
linkedIn | 20+ Multiple-Choice Questions On JavaScript Functions
Share

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Write A Comment

RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
Share