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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:00:58+00:00 2026-06-17T07:00:58+00:00

example = {}; example.Math = { sin: function() {console.log(‘sin’);}, cos: function() {console.log(‘cos’);} }; foo

  • 0
example = {};

example.Math = {
  sin: function() {console.log('sin');},
  cos: function() {console.log('cos');}
};

foo = function(){
   sin(); 
};
foo.prototype = window.example.Math;

console.log(foo.prototype)
console.log(foo.cos)
console.log(foo())

http://jsfiddle.net/Mubqy/9/

From what I thought I understood references are searched for through the scope chain. So theoretically if I assign an object with functions defined to a prototype I should get all of those functions and fields of the object or so I thought. Where is the error in my understanding? Neither of the above scenarios work. Additionally the internal proto variable is not being updated. Obviously that’s why it is not working, but why doesn’t my assignment to the prototype work?

  • 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-06-17T07:00:59+00:00Added an answer on June 17, 2026 at 7:00 am

    I think you need to realize that the prototyped method needs to be run with the new keyword, and it needs to use this to access its variables and methods, like this:

    example = {};
    
    example.Math = {
      sin: function() {console.log('sin');},
      cos: function() {console.log('cos');}
    };
    
    foo = function(){
       this.sin(); 
    };
    foo.prototype = window.example.Math;
    
    console.log(foo.prototype)
    console.log(foo.cos)
    console.log(new foo())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My python interpreter is acting funky when I use the math.cos() and math.sin() function.
Take a look at the example here: http://www.brianhare.com/physics/so.html Take a look at console.log where
I want to make a function that automatically turns every Math function global example:
I have the following code doing Sin/Cos function using a pre-calculated memory table. in
I'm trying math.sin and math.cos to do a moving edge line in my program.
For example, these are valid math expressions: a * b + c -a *
Common scenario: I have a library that uses other libraries. For example, a math
I'm trying to use a raphael.js example located here: http://raphaeljs.com/pie.html but I want to
I am using Math.PI in my example, so it is a double. It is
I am trying to utilize the example cited here: http://www.physicsforums.com/showthread.php?t=248191 I wrote a simple

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.