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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:45:12+00:00 2026-06-01T10:45:12+00:00

I have the following object: var r = { obj: $(this), children: $(this).children(), panes:

  • 0

I have the following object:

var r = {
    obj: $(this),
    children: $(this).children(),
    panes: $('.rotatorPane', $(this)),
    tagNames : [],
    captions: [],
    subcaptions: []     
};

$(this) refers to the following div:

<div class="myRotator">
    <div class="rotatorPane">

    </div>
    <div class="rotatorPane" id="pane3">

    </div>

    <img src="img/1.jpg" alt="pane 1" class="rotatorPane" data-caption="Lorem Ipsum" data-subcaption="Dolor sit amet" />

</div>

The problem I’m having is with the following for…in loop:

for(pane in r.panes){
    console.log(pane);
}

The output starts out as expected:

0
1
2

But then I get a bunch of method names as outputs:

length
prevObject
context
selector
constructor
init
jquery
size
toArray
get
...etc

Does anyone know why this is happening?

  • 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-01T10:45:14+00:00Added an answer on June 1, 2026 at 10:45 am

    Don’t use for ... in on things that are arrays, or array-like. Use a numeric index variable.

    for (var i = 0; i < r.panes.length; ++i) {
      var pane = r.panes[i];
      // ...
    }
    

    The for ... in form is for iterating over the properties of an object — all of them. When you want to iterate through the indexed properties of an array (or, again, something that you’re treating as an array), always use a numeric index.

    In this case, the array-like object in question is a jQuery object, which has all sorts of properties besides the numerically-indexed properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following classes. I have a object var of Description class. I
Let us presume I have the following object defined: var myObj = function(){ this.hello
I have the following object: var object = { property1: value1, property2: value2, subobject:
I have taken the following object as an example: var questions = { 1:
I have the following json object. var json1 = {00 : 00, 15 :
I have the following object defined function BusinessUnit(id, name, code) { this.id = ko.observable(id);
I have the following object: public class QueueItem { public long _id { get;
I have the following (nested) object: obj: { subObj: { foo: 'hello world' }
I have the following code #include <iostream> using namespace std; class Object { public:
I have the following code: class myClass { private delegate string myDelegate(Object bj); protected

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.