Home »
MCQs »
JavaScript MCQs
What is the output of the following JavaScript code? | Question 12
61. What will be the output of the following JavaScript code?
<script>
let cars = ['Honda', 'Hyundai'];
cars.push('Mahindra');
document.write(typeof cars + " " + cars);
</script>
- array Honda,Hyundai,Mahindra
- string Honda,Hyundai,Mahindra
- object Honda,Hyundai,Mahindra
- object "Honda", "Hyundai", "Mahindra"
Answer: C) object "Honda", "Hyundai", "Mahindra"
Explanation:
The push() method pushes an element at the end of the array. And, typeof returns the type of the object. Here, cars is an array.