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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:54:22+00:00 2026-05-16T23:54:22+00:00

I have an object var object= {} I put some data in the object

  • 0

I have an object

var object= {}

I put some data in the object and then I want to print it like this

document.write(object.term);

the term is a variable that changes depending on different situations. When I try printing this it comes up with undefined.

How would it be done?

Update:

this is the code I am dealing with. I guess it probably isn’t the same as what I said above because I am doing it in selenium with browsermob, I just thought it would be similar to document.write(). Here is the code

var numCardsStr = selenium.getText("//div[@id='set-middle']/div[2]/h2");

var numCards = numCardsStr.substr(4,2); 

browserMob.log(numCards);

var flash = {}

for(i=0; i<(numCards); i++){

var terms = selenium.getText("//div[@id='words-normal']/table/tbody/tr[" + (i + 2) + "]/td[1]");
var defs = selenium.getText("//div[@id='words-normal']/table/tbody/tr[" + (i + 2) + "]/td[2]");

flash[terms] = defs;

browserMob.log(flash.terms);

}
  • 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-05-16T23:54:23+00:00Added an answer on May 16, 2026 at 11:54 pm

    EDIT: You’re using two different variable names, flash and flashcards. I don’t know if they are meant to be the same thing, but you are setting the value using the [] notation, then getting it using . notation.

    Try:

    var flash = {};
    
    ...
    
    flash[terms] = defs;
    
    browserMob.log(flash[terms]);
    

    If term is a variable to represent the property you are retrieving, then you should use the square bracket notation for getting the property from the object.

    Example: http://jsfiddle.net/xbMjc/ (uses alerts instead of document.write)

    var object= {};
    
    object.someProperty = 'some value';
    
    var term = "someProperty";
    
    document.write( object[term] );  // will output 'some value'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object: var seriesOptions = { y: parseFloat($(this).find('y').text()).toFixed(2), color: colors[index], level :
I have the following object: var r = { obj: $(this), children: $(this).children(), panes:
i have seen this code : var myNet = require (net); and in some
I have an object var Messages = { 'fullName' : 'Tell us your cool
I have a object var foo = { jon : {age: 'old', feeling: 'sad'
I have the following classes. I have a object var of Description class. I
I have the following object: var object = { property1: value1, property2: value2, subobject:
Say I have a StringBuilder object var sb = new StringBuilder(); And an arbritrary
Let's say you have an object literal: var d = { x: +'35', y:
Lets say I have a Javascript object: var myObj = { property1 : 20,

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.