What will be the output of the following JavaScript code?
var a1 = [,,,];
var a2 = new Array(3);
0 in a1
0 in a2
a) true false
b) false true
c) true true
d) false true
Answer: a
Explanation: Array a1 is defined with null values. Therefore we can access the indexes 0, 1 and 2. But array a2 is only defined not declared. Therefore we cannot access index 0.
Related Posts
What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
document.getElementById(“demo”).innerHTML = Math.sqrt(49);
</script>What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
document.getElementById(“demo”).innerHTML = Math.floor(4.7);
</script>What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
document.getElementById(“demo”).innerHTML = Math.min(0, 150, 30, 20, -8, -200);
</script>What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
document.getElementById(“demo”).innerHTML = Math.abs(-4.5);
</script>What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
document.getElementById(“demo”).innerHTML = Math.sin(90 * Math.PI / 180);
</script>The new Java arrays can be created into JavaScript programs using which of the following classes?
The JavaScript classes can be instantiated using _____ operator.
Join The Discussion