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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:41:11+00:00 2026-05-17T02:41:11+00:00

How do I get a numeric or string value for a javascript object such

  • 0

How do I get a numeric or string value for a javascript object such as window instead of the string [object]

Looking for something like an object id, like 44001 or 0xFF0012 that is unique for that object

  • 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-17T02:41:11+00:00Added an answer on May 17, 2026 at 2:41 am

    Javascript doesn’t keep a python-like unique hash for each object. You could create a function to assign a unique string to an object, or retrieve the string if it’s already been assigned.

    var getUniqueId = (function(){
    
      // uncomment this block if you want to avoid memory leaks
      // in browsers with crappy garbage collectors.
      /*
      try {
        window.addEventListener('unload', cleanup);
        window.addEventListener('beforeunload', cleanup);
      } catch (_) { try {
        window.attachEvent('onunload', cleanup);
        window.attachEvent('onbeforeunload', cleanup);
      } catch (__){}}
    
      function cleanup () { guid.knownObjects.length=0; }
      */
    
      guid.knownObjects=[];
    
      return guid;
    
      function guid (obj) {
        for (var i=guid.knownObjects.length; i--;) {
          if (guid.knownObjects[i][0]===obj) return guid.knownObjects[i][1];
        }
        var uid='x'+(+(''+Math.random()).substring(2)).toString(32);
        guid.knownObjects.push([obj, uid]);
        return uid;
      }
    
    }());
    

    Testing it out:

    getUniqueId(window)
    > "x7onn8ne58ug"
    
    getUniqueId(document)
    > "x9jeriqjdf9o"
    
    getUniqueId(document)
    > "x9jeriqjdf9o"
    
    getUniqueId(window)
    > "x7onn8ne58ug"
    

    You can do console.dir(getUniqueId.knownObjects) for some useful debugging info.

    getUniqueId.knownObjects
    > [
      Array
      0: DOMWindow
      1: "x7onn8ne58ug"
      , 
      Array
      0: HTMLDocument
      1: "x9jeriqjdf9o"
      ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes the exception returns something like: ORA-06502: PL/SQL: numeric or value error: character string
I wanted to get the value of a Numeric cell as a simple string.
How to get the numeric value from the following string using regular expression AD
i want a function or a code to get numeric value from the string
By default, ColdFusion passes simple types (like numeric, string, and GUID) by value to
I am having string like: NSString *str = @Helloworld.123 456; I need to get
If I have a variable that is given a numeric value from a PHP
How to check whether a string contains any numeric value by jquery? I search
I receive a pointer numeric value like: 0xbfe0e6ac it is possible set int foo
I have a table with one numeric value (n) and three string values (a,b,c).

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.