Home »
MCQs »
JavaScript MCQs
What is the output of the following JavaScript code? | Question 16
65. What will be the output of the following JavaScript code?
<script>
var cars = ["Honda","Hyundai","Mahindra"];
var result = cars.shift();
document.writeln("Result: ", cars);
</script>
- Result: Honda,Hyundai,Mahindra
- Result: Honda
- Result: Hyundai,Mahindra
- Result: Honda,Mahindra
Answer: C) Result: Hyundai,Mahindra
Explanation:
In the above JavaScript code, we used the shift() method which is used to remove the first element of the given array and return that element. This method changes the length of the original array. Thus, the output would be "Result: Hyundai,Mahindra".