×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

What is the output of the following JavaScript code? | Question 17

66. What will be the output of the following JavaScript code?

<script>
	var cars = ["Honda","Hyundai","Mahindra"];

	var result = cars.unshift("Toyota", "Tata");

	document.writeln("[", result, "] ", cars);
</script>
  1. [5] Toyota,Tata,Honda,Hyundai,Mahindra
  2. [5]Honda,Hyundai,Mahindra,Toyota,Tata
  3. [2] Toyota,Tata
  4. [5] Honda,Hyundai,Toyota,Tata,Mahindra

Answer: A) [5] Toyota,Tata,Honda,Hyundai,Mahindra

Explanation:

In the above JavaScript code, we used unshift() method which is used to add one or more elements in the beginning of the given array and returns the updated array. This method changes the length of the original array. Thus, the output would be "[5] Toyota,Tata,Honda,Hyundai,Mahindra".

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.