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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:07:11+00:00 2026-06-07T09:07:11+00:00

I encounter something quite strange while trying to iterate properties of an object stored

  • 0

I encounter something quite strange while trying to iterate properties of an object stored
using jQuery data function.

Here is the thing (as an example) :

wrapper.data( 'infos', {
    label: $('input[name*="label"]').val(),
    amount: $('input[name*="amount"]').val(),
    etc..
});

Then i try to read values using :

$.each( wrapper.data('infos'), function(k,v) {
  console.log(k + ' > ' + v);
});

And i get a beautiful output like :

0 > undefined
1 > undefined
... 
239 > undefined

If i output this object as if, i can read properties without any difficulties.
Is it somehow related to jquery caching or something ?

  • 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-07T09:07:13+00:00Added an answer on June 7, 2026 at 9:07 am

    Because your object has a length property, it is being interpeted as an array as, in 1.7.2 at least, whether it’s an array or not is determined via:

    length = obj.length,            
    isObj = length === undefined || jQuery.isFunction( obj );
    

    So you should either;

    1. Call your length property something else
    2. Use a for / in loop instead.

      var data = wrapper.data('infos')
      
      for (var x in data) {
          if (data.hasOwnProperty(x)) { // omit properties from the prototype chain
              console.log(x + ' > ' + data[x]);
          }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using data.table. Indeed it is very fast and quite nice syntax.
I encounter a very strange situation with safari while not with other browsers (FF,
I've encountered something quite surprising when using generic constraints with inheritance. I have an
In jQuery whenever I encounter something like this: $(div#MyDiv)..... I generally say to the
This is something I encounter frequently, but I don't know the elegant way of
Today I encountered something strange: I tried to put a utility method into an
I think I encountered something extraordinary strange in VS 2008. All the array values
I encounter this issue pretty consistently when trying to merge a branch back into
Here where I work I am trying to get the MVC framework accepted as
I've encountered a problem while trying to use the answer from a NDSolve in

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.