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

Code:
<p id="demo"></p>  
<script>  
functionourFunction()  
{  
document.getElementById("demo").innerHTML=Math.abs(-7.25);  
}  
</script>  
  • (A) 7
  • (B) -7.25
  • (C) 25
  • (D) -7
πŸ’¬ Discuss
βœ… Correct Answer: (C) 25

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

Code:
<p id="demo"></p>  
<script>  
function Function1()  
{  
document.getElementById("demo").innerHTML=Math.cbrt(792);  
}  
</script>  
  • (A) 972
  • (B) 81
  • (C) 9
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) 972

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

Code:
<p id="demo"></p>  
<script>  
functionmyFunction()  
{  
document.getElementById("demo").innerHTML=Math.acos(0.5);  
}  
</script> 
  • (A) 01
  • (B) 4
  • (C) 00
  • (D) 047
πŸ’¬ Discuss
βœ… Correct Answer: (D) 047

Q. What we will get if we compare the "one" with "8" using the less than operator ("one"<8)?

  • (A) False
  • (B) True
  • (C) NaN
  • (D) Undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) False

Q. Which one of the following is known as the Equality operator, which is used to check whether the two values are equal or not:

  • (A) =
  • (B) ===
  • (C) ==
  • (D) &&
πŸ’¬ Discuss
βœ… Correct Answer: (C) ==

Q. Which one of the following operator returns false if both values are equal?

  • (A) !
  • (B) !==
  • (C) !=
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) !=

Q. In a case, where the value of the operator is NULL , the typeof returned by the unary operator is___.

  • (A) undefined
  • (B) string
  • (C) boolean
  • (D) object
πŸ’¬ Discuss
βœ… Correct Answer: (D) object
Explanation:

Let's solve it carefully:

In JavaScript, if the value is null, and you apply the typeof unary operator, for example:

typeof null

Then the result is: "object".

Reason:

  • It's a well-known historical bug in JavaScript:
    typeof null returns "object", even though null is a primitive.
  • This behavior is maintained for backward compatibility.

Therefore, the correct answer is:

(D) object

Q. What will be the output obtained by "shift ()" in the given code of JavaScript?

Code:
var a =[];  
a.unshift(5);  
a.unshift(22);  
a.shift();  
a.unshift(3,[4,5]);  
a.shift();  
a.shift();  
a.shift();  
  • (A) Exception is thrown
  • (B) [4,5]
  • (C) [3,4,5]
  • (D) 5
πŸ’¬ Discuss
βœ… Correct Answer: (D) 5

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

Code:
var sum=0;  
   
vararr=[101,150,201,30];  
   
arr.forEach(functionmyFunction(element)  
{  
    sumsum=sum+element;  
});  
document.writeln(sum);  
  • (A) 70
  • (B) 75
  • (C) 482
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 482

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

Code:
var values=["Three","two","one"];  
varans=values.shift();  
document.writeln(ans);  
  • (A) One
  • (B) two
  • (C) three
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (C) three