Q. What will be the output of the following JavaScript code?
Code:
<script>
let cars1 = ['Honda', 'Hyundai'];
let cars2 = cars1;
cars1.push('Mahinda');
document.write(cars1 + "---" + cars2);
</script>
β
Correct Answer: (B)
Honda,Hyundai,Mahinda---Honda,Hyundai,Mahinda