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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:59:24+00:00 2026-06-14T21:59:24+00:00

An API I’m connecting with, gives me back an object. One of its keys/properties

  • 0

An API I’m connecting with, gives me back an object. One of its keys/properties is called “length” and this triggers some strange behaviour:

var obj = {"text1":{"index":0,"lengt":5}}; //modified key for testing

$.each(obj.text1,function(k,v){     
    console.log ('i: '+k+' v: '+v); });

i: index v: 0  //this is the result I'm looking for
i: lengt v: 5

var obj = {"text1":{"index":0,"length":5}}; //original object 

i: 0 v: undefined // ????
i: 1 v: undefined 
i: 2 v: undefined 
i: 3 v: undefined 
i: 4 v: undefined 

I assume length is a reserved word, but that’s how the original object comes. What would be the best way to spot and skirt this issue?

Much thanks for any assistance.

  • 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-14T21:59:25+00:00Added an answer on June 14, 2026 at 9:59 pm

    This is a jquery “feature” ;-). According to the sources it treats a variable as an object if there is no length property defined:

    https://github.com/jquery/jquery/blob/master/src/core.js#L589

    var name,
        i = 0,
        length = obj.length,
        isObj = length === undefined || jQuery.isFunction( obj );
          ^---------
    

    And if isObj is false – then see https://github.com/jquery/jquery/blob/master/src/core.js#L608

    if ( isObj ) {
        // not your case, ommitted
    } else {
        for ( ; i < length; ) {
            if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
                break;
            }
        }
    }
    

    As you can see it iterates over i from 0 to length

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

Sidebar

Related Questions

The API gives the code as: public function up() { $this->addColumn('table_name', 'column_name', 'string', $options);
API documentation in Digg is totally confusing...does any one know how to count submissions
[api,[API,Apiales,Apiaceae,Apicomplexa lifecycle stages,Apia,Apicomplexa,Apidae,APIA Leichhardt Tigers,Apical consonant,Apical membrane]] How do i parse this JSON with
This API: /// Returns a list iterator of the elements in this list (in
_fullpath API of windows takes relative path and gives the corresponding absolute path. But,
//API class Node class Person extends Node object Finder { def find[T <: Node](name:
The api I'm calling returns a json object of validation errors with the HTTP
An api im using is providing me a date. This date is of type
The API says that the Alert Dialog can have one, two or three buttons,
android API 8. I'd like to show some data in a listView and 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.