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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:08:47+00:00 2026-05-23T22:08:47+00:00

I have this object, dive : var dive = new Foo.Bar(); And Foo.Bar looks

  • 0

I have this object, dive:

var dive = new Foo.Bar();

And Foo.Bar looks like this:

var Foo = {
    Bar: function() {
        ...
        return function() {
        // do stuff, no return
        };
    }
};

I’d like dive to have all the prototypes of another, existing object, however. Let’s say window.Cow.prototype is:

{
    moo: function() { ... },
    eat: function() { ... }
}

What do I need to do to Foo.Bar so that I can do this:

dive.moo();
dive.eat();
  • 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-23T22:08:48+00:00Added an answer on May 23, 2026 at 10:08 pm

    Thank you for the start, jimbojw! You were close, but you gave me enough information to get it:

    function Cow() {
        return {
            talk: function() {
                 alert("mooo");   
            }
        };   
    }
    
    var Foo = {
        Bar: function() {
            function result() {
                alert("Foo.Bar says...");
            };
            result.prototype = new Cow();
            return new result;
        }
    };
    
    new Foo.Bar().talk();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Objective-C code that looks like this: #define myVar 10 float f
I have a protocol in Objective-C, something like this: @protocol Handler +(NSString*) getValue; @end
I am new to Objective-C and I have no clue why this code is
I have this object graph, I want to map: abstract Account (username, password, ...)
I have this object: class a { public string Application; public DateTime From, To;
I have this object which is an instance of a superclass. I want to
I have the following code in my application: using (var database = new Database())
For instance... if I have a Module class: class Module{ var $page; function Module($page){
I would like to define the following function in Objective-C. I have provided pseudo-code
REAL newbie here to Objective C and Cocoa. I have this 'if statement' if

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.