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

  • Home
  • SEARCH
  • 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 8286367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:43:42+00:00 2026-06-08T11:43:42+00:00

I have a class that starts like this: function event() { this.event_id = null;

  • 0

I have a class that starts like this:

function event()
{
    this.event_id = null;

and then it all gets populated with an init function.

In another part of my script I can not access these variables.

If I run this code:

    console.log(my_event);
    console.log(my_event.event_id);

For the first line the console gives me a nice representation of the event object with the event_id populated, but for the second line it gives me null.

What’s going on? The variable should be public right?

Many thanks for any help.

  • 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-08T11:43:45+00:00Added an answer on June 8, 2026 at 11:43 am

    When you console.log a non-scalar value, such as an object, its actual state is retrieved only at the time when you expand to see the object properties in chrome developer tools console. Short arrays or array-likes of < 100 items will automatically expand though the state is usually (my test results have varied on this, maybe I’m just seeing things) not immediately retrieved in that case either.

    So if you get null from console.log(my_event.event_id);, then it was in fact null at the time that console.log executed. The results of console.log(my_event); depend on when you expand the logged object in console. If you made an ajax request that modifies the event_id property and the request was completed by the time you expanded the object in console, it will show the changed value.

    Also, every object property in javascript is “public”.

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

Sidebar

Related Questions

I have 4 buttons that when click starts a new activity class. This works
I have class that looks like this: class A { public: class variables_map vm
I have a class that gets a movieClip and then using addChild adds it
I have a Class that has a private variable with a public setter/getter function:
So, I have a function that executes on a .click() event. I want to
I have a simple span like so <span class=action removeAction>Remove</span> This span is within
I have a page like this : <div id=daysTable> <div id=day0 class=day></div> <div id=day1
hope you can help me. I have html markup like this: <a href=error.htm class=button
i would like to block a function and wait for an event then continue
I have this project that I'm working on for a class, and I'm not

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.