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

Code:
functionfun()  
{  
var a=1;  
var b=2;  
return a*b;  
}  
document.write(fun());  
  • (A) 2
  • (B) 3
  • (C) 0
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) 2

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

Code:
var arr=[1, 3, 5, 8 ,11];  
var value =Math.max.apply(null,arr);  
document.writeln(value);  
  • (A) 7
  • (B) 11
  • (C) 3
  • (D) 9
πŸ’¬ Discuss
βœ… Correct Answer: (B) 11

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

Code:
var person =  
{  
      name: "James",  
getName:function()  
{  
nreturnthis.name;  
}  
}  
varunboundName=person.getName;  
varboundName=unboundName.bind(person);  
document.writeln(boundName());  
  • (A) James
  • (B) compilation error
  • (C) runtime error
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) James

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

Code:
function code(id,name)  
{  
        this.id= id;  
        this.name= name;  
}  
functionpcode(id,name)  
{  
        code.call(this,id,name);  
}  
document.writeln(newpcode(004,"James Deo").id);
  • (A) James Deo
  • (B) compilation error
  • (C) runtime error
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) James Deo

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

Code:
var pow=newFunction("num1","num2","return Math.pow(num1,num2)");  
document.writeln(pow(2,3));  
  • (A) 8
  • (B) 3
  • (C) 6
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) 8

Q. Which one of the following keywords is used for defining the function in the JavaScript?

  • (A) Void
  • (B) init
  • (C) main
  • (D) function
πŸ’¬ Discuss
βœ… Correct Answer: (D) function

Q. In JavaScript, do the functions always return a value?

  • (A) Yes, functions always returns a value
  • (B) No, it is not necessary
  • (C) A number of functions return values by default
  • (D) some functions do not return any value
πŸ’¬ Discuss
βœ… Correct Answer: (C) A number of functions return values by default

Q. Which one of the following codes is correct for concatenating the strings passed into the function?

  • (A) functionconcatenate() { returnString.prototype.concat('', arguments); }
  • (B) functionconcatenate() { returnString.prototype.concat.apply('', arguments); }
  • (C) functionconcatenate() { returnString.prototype.apply('', arguments); }
  • (D) functionconcatenate() { returnString.concat.apply('', arguments); }
πŸ’¬ Discuss
βœ… Correct Answer: (B) functionconcatenate() { returnString.prototype.concat.apply('', arguments); }

Q. Which of the following values will be returned by the last statement in the given code?

Code:
functionconstfun()  
{  
var fun =[];  
for(vari=0;i<10;i++)  
        fun[i]=function(){returni;};  
return fun;  
}  
var fun =constfun();  
fun[5]()  
  • (A) 10
  • (B) 12
  • (C) 8
  • (D) 9
πŸ’¬ Discuss
βœ… Correct Answer: (C) 8

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

Code:
<p id="demo"></p>  
<script>  
functionFunct()  
{  
document.getElementById("demo").innerHTML=Math.atan2(8,4);  
}  
</script>  
  • (A) 1.01
  • (B) 1.10
  • (C) 1.05
  • (D) 1.11
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1.10