MCQs > IT & Programming > JavaScript > Which code snippet is more efficient, and why?

JavaScript MCQs

Which of the following code snippets is more efficient, and why?

<script language=”JavaScript”>

For(i=0; i<document.images.length;i++)

Document.images[i].src=”blank.gif”;

</script>

<script language=”JavaScript”>

Var theimages = document.images;

For(i=0;i<theimages.length;i++)

Theimages[i].src”blank.gif”

</script>

Answer

Correct Answer: The second code is more efficient as it employs object caching.

Explanation:

Note: This Question is unanswered, help us to find answer for this one

JavaScript Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

JavaScript Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it