Functions in Javascript

@T-Bone

This question paper focuses on the "Functions" of Javascript. These Multiple Choice Questions (mcq) should be practiced to improve the Javascript skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

This question paper focuses on the "Functions" of Javascript. These Multiple Choice Questions (mcq) should be practiced to improve the Javascript skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

Questions

1. Consider the JavaScript code: Identify the value that will be displayed in alert box at line 5? function lfc(myname){ console.log(10+"lfc" +12); } res=lfc(10); console.log(res); //line 5

Mark the correct option

2. Consider the JavaScript code: Choose the correct code to be inserted at line 4 in order to invoke the function. thisfun=function lfc(x){ console.log(x*x); } // line 4

Mark the correct option

3. What will be the output of the below code? function password(pass) { for (i = 0; i < pass.length; i++) { } } function name(pname) { console.log("The value of i is "+i); for (i = 0; i < pname.length; i++) { } } password("54321"); name("John");

Mark the correct option

4. What will be the output of the below code? let chaval= (p)=>p+2; console.log(chaval(2));

Mark the correct option

5. what will be the output of the below code? num1=5; function cal() { num1=10; num2=5; num3=num2*num1; console.log(num3); } cal();

Mark the correct option

6. Functions are invoked as functions or as methods with an __________.

Mark the correct option

7. ........ functions need not allow invocations with zero arguments.

Mark the correct option

8. When you invoke the........ method on a function f and pass an object o, the method returns a new function.

Mark the correct option

9. Variable declared is example of ___________ Variable. function message() { var name = "Bench"; alert(name); }

Mark the correct option

10. What is the output for code A and B? Code A: var x = 10; y = --x + 1; alert(y); Code B: var x = 10; y = x-- + 1; alert(y);

Mark the correct option

11. A _________ is a group of reusable code which can be called anywhere in your program.

Mark the correct option

12. The most common way to define a function in JavaScript is by using the ____________ keyword.

Mark the correct option

13. Which statement required if you want to return a value from a function?

Mark the correct option

14. Does JavaScript allows us to write our own functions as well?

Mark the correct option

15. The Function() constructor expects ______ number of string arguments

Mark the correct option

Index of Questions