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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:06:23+00:00 2026-05-27T04:06:23+00:00

I want to extend Object.prototype, to basically support notifications in JSON data and html

  • 0

I want to extend Object.prototype, to basically support notifications in JSON data and html elements through UI framework.

Object.prototype.setValue = function(key,value){
   // this simply sets value as this[key] = value
   // and raises an event
   Binder.setValue(this,key,value);
};
Object.prototype.getValue = function(key){
   return Binder.getValue(this,key);
};

However, based on this question, Extending Object.prototype JavaScript and few others, people say that we should avoid extending Object.prototype, instead any other type is fine.

If I do not do this, then my code becomes bigger, for example

window.myModel.setValue("currentStatus","empty");

will have to be written like,

Binder.setValue(window.myModel,"currentStatus","empty");

I want to know what will go wrong if I use these methods? will it cause jQuery to behave unexpectedly? I have seen once, that jQuery’s ajax request invokes prototype methods as well (as they references to functions for event handling).

What are other side effects of this? I know it fails for(var x in obj), but mostly we can use obj.hasOwnProperty, that should help 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-05-27T04:06:24+00:00Added an answer on May 27, 2026 at 4:06 am

    You just don’t want to mess with prototypes from host or native objects.

    • You cannot know which side effects it has on any third-party script
    • You may confuse third party code
    • You don’t know if some day those methods are created natively

    overall, extending Object.prototype effects any other object on the entire site. Again, you just don’t want to do it, unless, you are in such a sandboxed environment and every single piece of ecmascript is written on your own and you are 100% sure no third-party script is ever loaded.

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

Sidebar

Related Questions

I want to extend Array and Object like the following code: $(window).load(function() { Array.prototype.x
I want to be able to have an object extend Enumerable in Ruby to
Basically, I want to modify the constructor of the Object class. Since every class
I want to extend the VB.NET dictionary object to not bitch about an item
I need a List component that will display custom data. I want to extend
I want to extend the javascript object htmloptionscollection. How can I accomplish this? I
I want to extend Object to add a few methods. so I can do
I want to extend the Nokohiri::XML::Node object into my own unique object with custom
I want to extend the type 'Number' with a new function and hence I
Is it possible to extend the console object? I tried something like: Console.prototype.log =

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.