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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:25:44+00:00 2026-05-31T22:25:44+00:00

I wanted to use a hashtable as set of some objects for a graphic

  • 0

I wanted to use a hashtable as set of some objects for a graphic libray, so that I can quickly remove these objects by saying something like set.remove(v2).

But it appears I cannot use these objects while I try to iterate the set, since the keys don’t have the right properties, even though a == shows that they are the same objects!

What can I do to iterate the set and use the properties or functions which are part of the keys?

Test case shown below, with rather unexpected results (for me)!

v1={'a':2,'b':3};
set={};
set[v1]=true;

// Access the object within set
var v2; for(var k in set) v2=k;

// At this moment, v2 and v1 should be the same object, but...

console.log(v2==v1);    // returns true
console.log(JSON.stringify(v1)); // returns {"a":2,"b":3}
console.log(JSON.stringify(v2)); // returns "[object Object]"   !!!
console.log(v1.a);  // returns 2
console.log(v2.a);  // causes error 'reference to undefined property v2.a' !!!
  • 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-31T22:25:45+00:00Added an answer on May 31, 2026 at 10:25 pm

    You’re trying to set an object as the key of another object, which isn’t possible in current ECMAScript implementations. When you call set[v1]=true;, internally the engine converts v1 to a string, the result being "[object Object]" with no identifiable properties.

    ECMAScript 6 allows you to map objects to other values using WeakMap, but the API is still in the early stages and currently only available in Chrome—with a command line switch—and Firefox.

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

Sidebar

Related Questions

I wanted to use one of the Git-completion.bash features but I can't customize the
I wanted to use a python equivalent to piping some shell commands in perl.
I wanted to use the following code from here: How can I save all
I just wanted to use MySQLConnectionStringBuilder to build a connection string and realized that
I believe I read that if you wanted to use Google's App Engine, your
I wanted to use memcached for my C++ application. To do that I need
I recently wanted use regex in Cocoa app. But I found that Cocoa does
I wanted to use boost accumulators to calculate statistics of a variable that is
I wanted to use express with my node.js but now it says that my
I wanted to use a switch statement. I ran into difficulties quickly. It looks

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.