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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:40:06+00:00 2026-05-17T00:40:06+00:00

At work, we use jQuery. Shortly after we started using it, I saw that

  • 0

At work, we use jQuery. Shortly after we started using it, I saw that a couple developers were adding functions to a file jquery-extensions.js. Inside, I found a whole bunch of methods added to $ that essentially amount to static methods on jQuery. Here’s a few:

$.formatString(str, args) {
    ...
}

$.objectToArray(obj) {
    ...
}

Etc. None of them actually use anything to do with jQuery. This struck me as odd.

Eventually, we needed a function in our library to localize dates. My solution was to create:

Date.prototype.toLocaleDate = function() {
    ...
}

Date.parseLocalDate = function() {
   ...
}

Shortly after doing this, I get a Sr. Developer coming up to me asking me what I think I’m doing. He tells me that here, where I work, we don’t create prototypes because they’re evil. The only reasons he gave was that they’re fundamentally a poor language features because they “can be abused” and that it’s confusing to see prototypes (e.g. how do I know new Date().toLocaleDate() is a prototype and not native ECMAScript). By using $.formatString(...) instead of "blah blah".formatString(...), we’re keeping it clear that anything with a $ is not part of native JavaScript.

Those reasons seem a bit silly, but I offered a compromise so he wouldn’t have to remember whether a method was an prototype—prefix the prototype function name with $:

String.prototype.$format = function() {
    ...
}

"blah blah".$format(...);

That was quickly dismissed and now I’m having to add these $.myPrototypeAsAFauxStaticMethodOnjQuery() functions everywhere.

Am I the only one that thinks this practice is stupid?

  • 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-17T00:40:06+00:00Added an answer on May 17, 2026 at 12:40 am

    The native prototypes debate is a bit tired, there are valid points on both sides, I’ll try to summarize them in hope it might be useful to see the big picture.

    contra There’s no need to extend native prototypes. You’ve got everything you need.

    pro JS standard library is scarce to the extreme. Arrays and strings are lacking many vital features.

    contra Use functions or your own “namespaces”.

    pro Methods like foo.trim() are far more in the spirit of the language than functions like org.blah.trim(foo). Everything is object in javascript and let it be that way.

    contra Native JS objects are “reserved” for the language designers. Our methods can accidentally override newly added built-ins.
    pro Open objects is a great feature and it would be silly not to use it. A new Javascript version is not something that happens every day and additions to the standard are well known in advance.

    contra Extending native prototypes is confusing, because there’s no distinction between our and native methods.
    pro JS standard library is small and well documented. We javascript developers are supposed to know native methods’ names.

    contra Extending prototypes can lead to namespace conflicts.
    pro Yes, but this can happen with global functions or well-known global objects (like $) as well.

    contra Custom methods are enumerable.
    pro Yes, but there’s hasOwnProperty to the rescue. Wrap it in your own enumerator function and stop using raw for..in loops with objects.

    (not a real answer, hence CW)

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

Sidebar

Related Questions

My buddy at work told me that you could use jQuery to write a
I use Jquery fadeIn effect, but it does not work well in Chrome (neither
i try to use jquery .text() but not really work : Before <a id=group_name
How does collision detection work in JavaScript? I can't use jQuery or gameQuery -
At work we use a common makefile that other makefiles include (via the include
I am trying to use jQuery to fade out a div, using the fadeOut
I'm trying to use jQuery Corners 0.3, but it doesn't work in any other
I'm trying to use jquery ui resizable with iframe. It simply does not work,
I use jquery ajax to get data from the PHP file. data = <option>Peter</option><option>Maria</option>
I am trying to use jQuery's hasClass function. It doesn't seem to work when

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.