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 6996835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:12:29+00:00 2026-05-27T20:12:29+00:00

used to be able to do this without any problems: for (data in dataArray)

  • 0

used to be able to do this without any problems:

for (data in dataArray) { // do some stuff };

now, it suddenly is iterating through this __proto__ array that got added to my dataArray. where the hell did it come from? is this from using the MooTools library? it’s breaking all my loops! 😛 now i have to do this instead:

for (var i=0; i < dataArray.length; i++) { // do some stuff };

the thing i DO NOT get is why this works… does __proto__ not actually count as an array element? if not, then why does the first version not work like it used to, but the second does?

TIA for turning some lights on…

WR!

  • 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-05-27T20:12:29+00:00Added an answer on May 27, 2026 at 8:12 pm

    no. javascript is prototypical. it means that anything (any native type) can be extended by modifying its prototype. eg, if you want to add a new method that allows you to iterate through any array you may later create, you’d do:

    Array.prototype.each = function(callback) {
        // this == the array. code here...
        return this;
    };
    

    this means any array created will support .each after: [].each(function(el) {});. and yes, mootools is a heavily prototypical framework AT THE MOMENT. things are changing with mootools milk, which goes AMD – hence without extending natives…

    ultimately, though, in javascript everything inherits from the Object native through the prototype chain.

    as for Array, it’s not really a proper Array Type – in javascript, it’s more like an Object with array-like properties. which brings me to why you have the problem you have:

    for (var foo in obj) is actually a way of looping Objects – not Arrays. it works on arrays as well, because they are kind of like Objects as I mentioned.

    but it’s the wrong thing to do, especially when you work with a prototypical framework or you are not sure of all the code you run and how it has affected the prototype chain. if you mean to use what is known as an ‘associative array’ in other languages, simply use an Object.

    In mootools, you can use Object.each(function(value, key) {}); to iterate them.

    Or: in your loop check to see if the item hasOwnProperty:

    for (var data in dataArray) {
        if (dataArray.hasOwnProperty(data)) {
            // avoids working with prototype.
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used to be able to do this to create an exported HTML page
I seem to not be able to do this (which I used to be
I have been struggling with this for some time now scanning the net for
I've been trying to figure out how to detect this for months without any
I used to be able to do the following in Preview 3 <%=Html.BuildUrlFromExpression<AController>(c =>
I used to be able to right click Folders in my project and click
I used to be able to open a new buffer in Emacs quickly using
As of SQL Server 2005, you used to be able to open a flat
With combo box controls, I'm used to being able tab to them, click the
I apologize in advance for the long post... I used to be able to

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.