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

DHTML 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

DHTML Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

DHTML Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it