Q. Which is an equivalent code to invoke a function fun of class opt that expects two arguments p and q?

  • (A) opt.fun(p,q);
  • (B) fun(p,q);
  • (C) opt.fun(p) && opt.fun(q);
  • (D) opt(p,q);
πŸ’¬ Discuss
βœ… Correct Answer: (A) opt.fun(p,q);

Q. Which of the following is the correct code for invoking a function without this keyword at all, and also too determine whether the strict mode is in effect?

  • (A) mode strict = (function { });
  • (B) var strict = (function { return this; });
  • (C) mode strict = (function() { return !this; }());
  • (D) var strict = (function() { return !this; }());
πŸ’¬ Discuss
βœ… Correct Answer: (D) var strict = (function() { return !this; }());

Q. Consider the following code snippet.
What will be the result of this code?

Code:
function hypotenuse(p, q) 
{
       function square(n) 
       { 
            return n*n; 
       }
       return Math.sqrt(square(p) + square(q));
}
  • (A) Square of sum of p and q
  • (B) Sum of p and q square
  • (C) Sum of square of p and q
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Sum of square of p and q

Q. A function with no return value is called

  • (A) Dynamic function
  • (B) Static function
  • (C) Method
  • (D) Procedures
πŸ’¬ Discuss
βœ… Correct Answer: (A) Dynamic function

Q. What will happen if a return statement does not have an associated expression?

  • (A) It will throw an exception
  • (B) It will throw an error
  • (C) It returns the value 0
  • (D) It returns the undefined value
πŸ’¬ Discuss
βœ… Correct Answer: (D) It returns the undefined value

Q. What is the purpose of a return statement in a function?

  • (A) Stops executing the function and returns the value
  • (B) Returns the value and stops executing the function
  • (C) Returns the value and stops the program
  • (D) Returns the value and continues executing rest of the statements, if any
πŸ’¬ Discuss
βœ… Correct Answer: (A) Stops executing the function and returns the value

Q. When does the function name become optional in JavaScript?

  • (A) When the function is predefined
  • (B) when the function is called
  • (C) When the function is defined as expressions
  • (D) When the function is defined as a looping statement
πŸ’¬ Discuss
βœ… Correct Answer: (C) When the function is defined as expressions

Q. Consider the following code snippet.
What will the above code snippet result ?

Code:
function output(n) 
{
    for(var v in n)
      console.log(v + ": " + n[v] + "\n");
}
  • (A) prints only one property
  • (B) Prints the contents of each property of n
  • (C) prints the address of elements
  • (D) Returns undefined
πŸ’¬ Discuss
βœ… Correct Answer: (D) Returns undefined

Q. The function definitions in JavaScript begins with

  • (A) Return type and Identifier
  • (B) Return type, Function keyword, Identifier and Parentheses
  • (C) Identifier and Return type
  • (D) Identifier and Parentheses
πŸ’¬ Discuss
βœ… Correct Answer: (B) Return type, Function keyword, Identifier and Parentheses

Q. Among the keywords below, which one is not a statement?

  • (A) use strict
  • (B) if
  • (C) with
  • (D) debugger
πŸ’¬ Discuss
βœ… Correct Answer: (A) use strict