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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:47:19+00:00 2026-05-15T02:47:19+00:00

What ugliness does the following solve? There’s something I’m not getting, and I’d appreciate

  • 0

What “ugliness” does the following solve? There’s something I’m not getting, and I’d appreciate help understanding what it is.


For example, by augmenting Function.prototype, we can make a method available to all functions:

Function.prototype.method = function (name, func) {
     this.prototype[name] = func;
     return this; 
};

By augmenting Function.prototype with a method method, we no longer have to type the name of the prototype property. That bit of ugliness can now be hidden.

  • 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-15T02:47:20+00:00Added an answer on May 15, 2026 at 2:47 am

    Well, ugliness is subjective, but let’s see.

    You usually write:

    function Foo () {}
    Foo.prototype.method1 = function ()  { /*...*/ };
    Foo.prototype.method2 = function ()  { /*...*/ };
    

    You extend the prototype object a constructor function with the properties that you want to be inherited to the instances created by the new operator.

    For example with var obj = new Foo(); you are creating an instance of the Foo constructor, that object will inherit the all the properties bound to the Foo.prototype object and other objects higher in the prototype chain.

    The Crockford’s method does the same, that method is defined in the Function.prototype object, all functions inherit from that object, so you can call the method like this:

    function Foo () {}
    Foo.method('method1', function () { /*...*/ });
    Foo.method('method2', function () { /*...*/ });
    

    It basically just hides the prototype word from the code, which Crockford considers ugly…

    “JavaScript The Good Parts” is a really good book, but I think is based on the personal perspective that Douglas Crockford has of the language.

    I agree with him with a lot of things, but I also disagree with some aspects…

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

Sidebar

Related Questions

Consider the following simple RESTEasy (JAX-RS) service: @Path(/example-service) public interface ExampleService { @Path(/ping) @GET
I have a fiddle to help me in my understanding of JavaScript prototyping and
for example: this code: <asp:LinkButton ID=SignInLinkButton runat=server CssClass=SignInLinkButton TabIndex=3 OnClick=AuthorizeUser>SignIn</asp:LinkButton> shows this as link
Python doesn't support complicated anonymous functions. What's a good alternative? For example: class Calculation:
function addRequest(req) { try { request = new XMLHttpRequest(); } catch (e) { try{
I have a page where the following occurs: some stuff is rendered. static content,
Sorry I suspect the answer is easy but I'm getting annoyed at the way
In my current project, the compiler shows hundreds of warnings about type conversions. There
My code looks ugly, and I know there's got to be a better way
I'm writing a wizard UI based on the QWizard Qt object. There's one particular

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.