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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:50:05+00:00 2026-06-02T23:50:05+00:00

I have a javascript object and I need to reference the value of one

  • 0

I have a javascript object and I need to reference the value of one of it’s children. The child should be part of an array.

This works:

this.manager.response.highlighting[doc.id]['sentence_0002']

But this doesn’t:

this.manager.response.highlighting[doc.id][0]

I don’t know which sentence_000* numbers are going to be returned, so I want to reference it by it’s array number.

this.manager.response.highlighting[doc.id].length

doesn’t return anything either.

Here is a portion of the xml document that was turned into the javascript object:

<response>
  <lst name="highlighting">
    <lst name="http://www.lemonde.fr/international/">
      <arr name="sentence_0005">
        <str> puni pour sa gestion de la crise Geir Haarde a été condamné pour avoir manqué aux devoirs de sa </str>

What I need to access is the value in <str>. doc.id is successfully set to http://www.lemonde.fr/international/.

  • 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-02T23:50:06+00:00Added an answer on June 2, 2026 at 11:50 pm

    If highlighting[doc.id] has a property with a name like sentence_xyz, there is no positional order to that property, but you can find out what keys exist using a for..in loop:

    var key, val;
    var obj = this.manager.response.highlighting[doc.id];
    for (key in obj) {
        // Here, `key` will be a string, e.g. "sentence_xyz", and you can get its value
        // using
        val = obj[key];
    }
    

    You may find you need to filter out other properties, which you can do with the usual string methods, e.g.:

    for (key in obj) {[
        if (key.substring(0, 9) === "sentence_") {
            // It's a sentence identifier
        }
    }
    

    You may also find hasOwnProperty useful, though I’m guessing this is a deserialized object graph from a JSON text response, in which case hasOwnProperty doesn’t really come into it.

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

Sidebar

Related Questions

In javascript if I need objects each to have an individual value of an
Suppose I have a javascript object like this: window.config config.UI = { opacity: {
Hi I have a javascript array object rapresenting the amount of items sold in
I have a javascript function (class) that takes a function reference as one paremter.
I have a Javascript object like this: var count = { table:19, people:39, places_details:84,
I have a JavaScript Object with some information in it. I have 2 options
I have a Javascript object that requires 2 calls out to an external server
I have a Javascript object that basically represents a Row in an .NET GridView.
I have a JavaScript object with thousands of properties and what i want if
I have a javascript object with a bit of jquery for visual effect. I

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.