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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:49:38+00:00 2026-06-10T10:49:38+00:00

I search a way to get in Javascript an object which index by reference.

  • 0

I search a way to get in Javascript an object which index by reference.

something like:

var myRefMap = new RefMap();

var a = [{}, [], function () {}];

myRefMap.set(a[0], true);
myRefMap.set(a[1], { hello: 'world' });
myRefMap.set(a[2], 42);

myRefMap.has(a[0]); // true
myRefMap.has(a[1]); // true
myRefMap.has(a[2]); // true

myRefMap.has({});             // false
myRefMap.has([]);             // false
myRefMap.has(function () {}); // false

I need this object in order to optimize and avoid an actual heavy array search, during tree browsing within circulars references.

Thanks,

  • 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-10T10:49:39+00:00Added an answer on June 10, 2026 at 10:49 am

    One basic way to do this, provided all the stored values are objects would be something like:

    (function () {
        var instCount = 0;
        self.RefMap = function () {
            instCount ++;
            var propName = '__RefMap' + instCount + '__';
            this.has = function (o) {
                return propName in o;
            };
            this.set = function (o) {
                o[propName] = true;
            }
            this.remove = function (o) {
                delete o[propName];
            }
        }
    }());
    
    //then use it like
    var myRefMap = new RefMap();
    

    Edit: Arrays and functions are objects too. And you can use Object.defineProperty to hide the “marking” property, depending on the browsers you target.

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

Sidebar

Related Questions

I'm using the following javascript to get URL parameters... function getUrlParams() { var params
In JavaScript, we can get a number representing the current date/time like so: var
I searched Google search APIs and didn't find a way to get a website
Is there a way to search for a file in a subversion repository? Something
I want to get an object's absolute x,y position on the page in Javascript.
I have this form : <form method='GET' name='search' action='index.php?explore=search'> <input type=hidden name=searchType value=all />
Is there any way to get the apple-style text box, like this: I want
Is there a way to get the script for search results from an HTTPS
I'm trying to write a Javascript function to get the query string of the
I'm using Freebase Suggest, a JQuery search form: <script type=text/javascript> $(function() { $(#game-search).suggest({type:'/games/game'}).bind(fb-select, function(e,

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.