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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:30:20+00:00 2026-06-14T17:30:20+00:00

I have a json object which is variable (with possibly infinite sub-structures): var myObject={

  • 0

I have a json object which is variable (with possibly infinite sub-structures):

var myObject={
    s1:{
        s2:'2',
        s3:'3'
    },
    s4:'4',
    s5:{
        s6:undefined
    },
    s7:'7'
};

I would like to find the first undefined member and to return it’s reference,
to be able to modify it anytime (by event triggered functions)

function findFirstUndefined(obj){
    for (var key in obj){
        if (typeof(obj[key]) === 'object'){
            var recursion=findFirstUndefined(obj[key])
            if (recursion!==false){
                return recursion;
            }       
        }
        else if (obj[key]===undefined){
            return obj[key];
        }   
    }
    return false; 
}

But it doesn’t return the reference of the member, but it’s value:

var subObj=findFirstUndefined(myObject);
subObj="my updated cool var!!";

doesn’t modify the object.

I found that a library like JsonPath could do the trick,
but it seems to me kind of heavy for such a simple task.

Wouldn’t it exists an elegant way to do so? Thank’s!

  • 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-14T17:30:22+00:00Added an answer on June 14, 2026 at 5:30 pm

    JS doesn’t do that. You could instead return a function that will assign to the missing entry?

    return function(v) { obj[key] = v; };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JSON object inside variable like this: var chessPieces = { p-w-1 :
I have json object like this, the site is running codeigniter which is ultimately
I have a JSON object which is generated by PHP. It's an object with
I have created an empty json object having an array itemlist(which further contains itemid
I have a form field which requires a json object as its value when
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I have several TextField columns on my UserProfile object which contain JSON objects. I've
I have a json object that looks something like this: Array ( [algorithm] =>
I am trying to retrieve data in a JSON object (which I have validated
I have the following json data in a Javascript variable result : [ Object

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.