ExamVeda
Login
Home
11
The function definitions in JavaScript begins with
Discuss
Answer & Solution
Answer: Option A
Solution:
The function definitions begin with the keyword function followed by an identifier that names the function and a pair of parantheses around a comma-separated list of zero or more identifiers.
12
Consider the following code snippet
function printprops(o) 
{
  for(var p in o)
  console.log(p + ": " + o[p] + "n");
}
What will the above code snippet result ?
Discuss
Answer & Solution
Answer: Option B
Solution:
The above code snippet returns undefined.
13
When does the function name become optional in JavaScript?
Discuss
Answer & Solution
Answer: Option B
Solution:
The function name is optional for functions defined as expressions. A function declaration statement actually declares a variable and assigns a function object to it.
14
What is the purpose of a return statement in a function?
Discuss
Answer & Solution
Answer: Option D
Solution:
The return statement causes the function to stop executing and to return the value of its expression (if any) to the caller.
15
What will happen if a return statement does not have an associated expression?
Discuss
Answer & Solution
Answer: Option C
Solution:
If the return statement does not have an associated expression, it returns the undefined value.
16
A function with no return value is called
Discuss
Answer & Solution
Answer: Option A
Solution:
Functions with no return value are sometimes called procedures.
17
Consider the following code snippet
function hypotenuse(a, b) 
{
  function square(x) 
  { 
    return x*x; 
  }
  return Math.sqrt(square(a) + square(b));
}
What does the above code result?
Discuss
Answer & Solution
Answer: Option A
Solution:
The above code snippet contains nested function in which the function hypotenuse(a,b) has another function inside its scope, function square(x). The interesting thing about nested functions is their variable scoping rules. They can acceess the parameters and variables of the function (or functions) they are nested within.
18
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?
Discuss
Answer & Solution
Answer: Option C
Solution:
The above code defines and invokes a function to determine if we’re in strict mode.
19
Which is an equivalent code to invoke a function m of class o that expects two arguments x and y?
Discuss
Answer & Solution
Answer: Option D
Solution:
The code above is an invocation expression: it includes a function expression o.m and two argument expressions, x and y.
20
Consider the following code snippet :
var grand_Total=eval("10*10+5");
The output for the above statement would be :
Discuss
Answer & Solution
Answer: Option C
Solution:
Even if the string value passed as a parameter to eval does represent a numeric value the use of eval() results in an error being generated.