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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:14:36+00:00 2026-05-27T12:14:36+00:00

i have a question regarding defining objects in modules. lets say i have a

  • 0

i have a question regarding defining objects in modules.

lets say i have a module:

/*---obj----*/
function A (param){
this.parm=param;
function func(){
//do somthing
 }
}
exports.func=func;

/*---file.js----*/
obj=require('obj');

function fileFunc(A){
A.func();//with out this line it works fine
A.param=2;
 }
}

for some reason it does not recognize the function in the object A. it recognizes the object A and its different vars, but when it comes to executing the function it gives the msg:
TypeError: Object # has no method ‘func’

i tried also to export the function in A by:
exports.A.func=A.func

or
exports.func=func
neither works..

does someone have a clue?

thanx
matti

  • 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-27T12:14:37+00:00Added an answer on May 27, 2026 at 12:14 pm

    The function you defined inside of A is local only to that function. What you want is

    function A(param) {
      this.param = param;
    }
    
    A.func = function() {
      // do something
    };
    

    But if you are treating A as a constructor then you’ll want to put that function in A’s prototype

    A.prototype.func = function() {
      // do something
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question regarding the use of function parameters. In the past I have
I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
I have a question regarding dependency injection. say i want to create a class
I have a question regarding static function in php. let's assume that I have
I have a question regarding the integration of business objects developed using Linq To
I have question regarding polymorphism about its assignment statement, for Example this is The
I have a question regarding inheritance in Java. If I have this base class
I would have question regarding web services. Let's say I have webservice client that
I have question regarding RESTful resources similar to this other question . We're also
I have question regarding the CreateWindowEx function. I have 2 windows, a main one

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.