Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:19:31+00:00 2026-06-11T17:19:31+00:00

HTML : <body> <canvas id=canvas1></canvas> <canvas id=canvas2></canvas> </body> Javascript : window.onload = function() {

  • 0

HTML :

<body>
  <canvas id="canvas1"></canvas>
  <canvas id="canvas2"></canvas>
</body>

Javascript :

window.onload = function() {
  var canvasElements = document.getElementsByTagName("canvas");
  for ( var index in canvasElements) {
  }
  for ( var index = 0; index < canvasElements.length; index++) {
  }
}

These two loop does not have same iteration number. Do you know why ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:19:32+00:00Added an answer on June 11, 2026 at 5:19 pm

    document.getElementsByTagName("canvas") returns an HTMLCollection that have one propertie, “length” and two methods, “item” and “namedItem”.

    So the FOR … IN loop iterate over items in that collection and over the members of the HTMLCollection.
    So There is 5 iterations:

    • 2 iterations for each HTMLElement, here canvasElement
    • 2 iterations for eahc methods : item, namedItem
    • 1 iteration for the propertie : length

    The for(…;…;…) loop only iterate over items because document.getElementsByTagName(“canvas”)[index] refere to an item

    Hope this response was clear !
    Ask for more information otherwise…

    Some references :

    • https://developer.mozilla.org/en-US/docs/DOM/HTMLCollection
    • https://developer.mozilla.org/en-US/docs/DOM/HTMLElement
    • http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement
    • http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037
    • http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-75708506
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<!DOCTYPE html> <html> <head> <title> New Document </title> <script type=text/javascript> window.onload = function ()
So i got this snippet of code: $(document).ready(function () { var replacementDoneIn = $(body).html();
Following is the javascript code var text; var name; window.onload = init; function init()
The recursive setTimeout function getRandomProducts is called onload in the html body tag, and
I have the following HTML... <body onload=draw();> <p><a href=><canvas class=demo2 width=6 height=12>Fallback</canvas> Back to
I made this Greasemonkey script: var maxpi = 250; var p1 = /html/body/div/div[2]/div/div[2]/table[2]/tbody/tr[1]/td[11]; var
$('a').click(function(event){ $('body').html('loading...'); $.post('www.sitename.com/hello',{site:http//:www.google.com},function(data) { alert(data); }); event.preventDefault(); }); I am using the above script
I tried the following: $.load(Views/chatBox.html).appendTo('body') Console Output: TypeError: $.load is not a function EDIT
how can i convert xpath like /html/body/div[3]/ul/li[1]/a[5] html > body > div[3] > ul
How do i add a new line characters to html body of mail composer?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.