Q. What will be the output of the following JavaScript code?

Code:
<script>  
var string1=[1,2,3];  
  
var string2=[4,5,6,7,8,9,10];  
var result=string1.concat(string2);  
document.writeln(result);  
</script>  
  • (A) 1, 2, 3
  • (B) Error
  • (C) It will concatenate both the stings and print as 1, 2, 3, 4, 5, 6, 7, 8, 9 ,10
  • (D) It will print nothing
πŸ’¬ Discuss
βœ… Correct Answer: (C) It will concatenate both the stings and print as 1, 2, 3, 4, 5, 6, 7, 8, 9 ,10

Q. What is the primary role of the "return ()" statement in a function body?

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

Q. If a function which does not return a value is known as

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

Q. The execution of a function stops when the program control encounters the _________ statement in the body of the function.

  • (A) return statement
  • (B) continue statement
  • (C) break statement
  • (D) goto statement
πŸ’¬ Discuss
βœ… Correct Answer: (A) return statement

Q. In which events/scenarios, A function name gets optional in JavaScript?

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

Q. In JavaScript, the definition of a function starts with____

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

Q. What happens if the return statement has no related expression?

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

Q. Which one of the following options is the correct output for the given code of JavaScript?

Code:
<script>  
functionprintprops(o)  
{  
for(var ain o)  
console.log(a+": "+ o[a]+"\n");  
}  
</script>  
  • (A) Prints the contents of each property of o
  • (B) Prints the address of elements
  • (C) Prints only one property
  • (D) Returns undefined
πŸ’¬ Discuss
βœ… Correct Answer: (D) Returns undefined

Q. Which one of the following code is equivalent to call a function "x" of the class "a" which have two arguments g and h?

  • (A) a,x(g,h);
  • (B) x(g) &&a.x(g);
  • (C) x(a,g);
  • (D) (g,h);
πŸ’¬ Discuss
βœ… Correct Answer: (A) a,x(g,h);

Q. Which one of the following code is equivalent to the following given code?

Code:
a.x(g,h);  
  • (A) x (g) &&a.x (h);
  • (B) a [ "x" ] ( g , h );
  • (C) a (x )[ "g" , "h" ];
  • (D) x( g&&h );
πŸ’¬ Discuss
βœ… Correct Answer: (B) a [ "x" ] ( g , h );