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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:59:04+00:00 2026-05-23T16:59:04+00:00

Object has Object.toString , a method that you can call on any object. When

  • 0

Object has Object.toString, a method that you can call on any object. When iterating through the property list, or, just doing a console.log(obj), you will not see toString come up as a property of an object. It is hidden.

I want to add a new method on to the Object primitive, using Object.prototype.myMethod. I do not however want it to come up every time I iterate through an object. I would like it hidden.

How can I do that?

  • 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-23T16:59:04+00:00Added an answer on May 23, 2026 at 4:59 pm

    You can do that with ECMAScript 5’s defineProperty [docs]:

    Object.defineProperty(Object.prototype, 'myMethod', {
        value: function() {
            // your function
        },
        enumerable: false // default is already `false`
    });
    

    Obviously this does not work in browsers that don’t support ES5 (especially IE8 and earlier).

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

Sidebar

Related Questions

Do you generally assume that toString() on any given object has a low cost
If an object has a property that is a collection, should the object create
Sometimes I want to know if an object has a property that I am
I have a vector class that has it's Equals(object obj) method overridden so that
When an object has various formats (XML,CSV) it can be represented in, where should
the window.open() object has some funky parameter list... is there a way to do
The generic list class has a .ForEach(Action<T> action) method. Now i've done some simple
For pupose of explaining let's say that I have a Company object which has
Has anyone else run into this problem before? I've got a method that calls
I have a helper method that serialises an object, which works until you try

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.