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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:04:59+00:00 2026-06-06T11:04:59+00:00

I’m learning JavaScript and there’s an example in the book I’m using that I

  • 0

I’m learning JavaScript and there’s an example in the book I’m using that I didn’t understand.
It’s like this:

var chineseBox = {};
chineseBox.content = chineseBox;

Then the book lists two expressions and their values. First, "content' in chineseBox; that returns true. Then, the one I don’t get, "content" in chineseBox.content which also returns true.
I think it’d be more natural if the second expression evaluated to false, pointing to the empty chineseBox object defined earlier.
Is there a reason to work like this? What are the practical implications of this feature?
And how do I explore deeper levels of the object? Is chineseBox.content.content right?

  • 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-06T11:05:00+00:00Added an answer on June 6, 2026 at 11:05 am

    I think it’d be more natural if the second expression evaluated to false, pointing to the empty chineseBox object defined earlier.

    It’s not empty anymore. As of chineseBox.content = chineseBox, it now has a property.

    When you assign object references to things (variables, properties, etc.), the value stored is a reference to the object, not a copy of it. So both chineseBox (the variable) and chineseBox.content (the property) point to the same object, which has a property called content.

    Let’s throw some ASCII art at this:

    var chineseBox = {};
    

    That gives us:

    +−−−−−−−−−−−−−−−−−−−−−−−+
    | chineseBox (variable) |
    +−−−−−−−−−−−−−−−−−−−−−−−+          +−−−−−−−−−−−−−−−+
    | value                 |−−−−−−−−−>|    (object)   |
    +−−−−−−−−−−−−−−−−−−−−−−−+          +−−−−−−−−−−−−−−−+
                                       |               |
                                       +−−−−−−−−−−−−−−−+
    

    Now we do

    chineseBox.content = chineseBox;
    

    …and we have:

                                                /−−−−−−−−−−−\
    +−−−−−−−−−−−−−−−−−−−−−−−+                   |           |
    | chineseBox (variable) |                   v           |
    +−−−−−−−−−−−−−−−−−−−−−−−+          +−−−−−−−−−−−−−−−+    |
    | value                 |−−−−−−−−−>|    (object)   |    |
    +−−−−−−−−−−−−−−−−−−−−−−−+          +−−−−−−−−−−−−−−−+    |
                                       |  content      |−−−−/
                                       +−−−−−−−−−−−−−−−+
    

    There’s just one object. There are two references pointing to it.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

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.