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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:05:14+00:00 2026-05-16T11:05:14+00:00

Would you consider extending the native elements via the prototype dangerous? I see some

  • 0

Would you consider extending the native elements via the prototype dangerous? I see some frameworks such as Prototype doing this so I have started to wonder if I dare to do that too.

I am worried about implementing things like addClassName and make it collide in the future in a way that I can’t resolve any other way than rewriting the software and asking module authors to do the same.

  • 1 1 Answer
  • 1 View
  • 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-16T11:05:14+00:00Added an answer on May 16, 2026 at 11:05 am

    I wouldn’t because IMHO it might definitely make collisions soon or later and create a potential bug very difficult to be spot out.

    I anyway do extend some basic simple native Javascript objects like String.trim, I’m anyway careful to always test to see if it already exists by using a simple if test:

    if(!String.prototype.trim)
       String.prototype.trim = function() { return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }
    

    You could do the same with addClassName.
    The difference is that doing it with simple function like String.trim, it’s difficult that might lead to problems in future, because even if a browser engine has got String.trim (actually FF has it) well such a function is going exactly to do what my String.trim does, so you won’t see differences in your web application workflow ever.

    A more complex function like overriding querySelectorAll might lead to differences between how the browser implements it and your implementation. For example: the order of the returned elements might be different, the browser function returns a collection while your one an array, and other issues. So when you run your webapp on browser that does implement the querySelectorAll it might lead to having your webapp not working anymore as expected, and there try finding out the bug!!!

    Maybe querySelectorAll is not the best example, but I hope I explained the concept.

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

Sidebar

Related Questions

I have what I would consider a small sized iPhone app that uses SQLite.
Are there some standards that you consider to be so obvious that they would
I'm experiencing what I would consider somewhat strange behavior. Specifically if I have a
What shortcut sets have you seen that you would consider logical and easy to
Okay, normally I would consider myself an intermediate user of jquery, but this seems
So I would consider myself a .Net and ASP.NET pro but I am a
Would you consider it bad practice to store various user data in a database
Consider the Java code below, what would happen if there were no paintComponent method
Consider: var object = { foo: {}, bar: {}, baz: {} } How would
Consider a disk file containing 100 records a. How many comparisons would be required

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.