Home »
MCQs »
JavaScript MCQs
What is the output of the following JavaScript code? | Question 22
79. What will be the output of the following JavaScript code?
<script>
try{
const cars = {
company: 'Honda'
};
delete cars.company;
document.write(cars.company);
}
catch (err){
document.write(err.message);
}
</script>
- undefined
- Honda
- ValueError
- TypeError
Answer: A) undefined
Explanation:
In the above JavaScript code, the statement delete cars.company; will delete the property. Thus, the output would be "undefined".