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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:59:26+00:00 2026-06-06T18:59:26+00:00

In the js code specified below – var tclass = function(){ this.func2=function(){console.log(‘func2’)}; this.b={ func1:

  • 0

In the js code specified below –

var tclass = function(){
   this.func2=function(){console.log('func2')};
   this.b={
      func1: function(){console.log('func1')}
   }
}

how do i call func2 inside func1 on the same instance?

  • 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-06T18:59:28+00:00Added an answer on June 6, 2026 at 6:59 pm

    You’d have to keep a reference to both this and that function in the closure.

    var tclass = function(){
       var obj = this;
       function func2(){console.log('func2')};
       this.func2 = func2;
       this.b={
          func1: function(){ obj.func2(); }
       }
    }
    

    Also it’s more useful to declare functions with actual function declaration statements:

    function tclass() {
      // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below specified code runs fine in ruby(console) irb but when i put this same
Below code gives this error message Specified method is not supported. But here is
In the code below I call a function (it happens to be a constructor)
I have some code like below $(html).on(change, input['data-href'], function() { var href, obj, params;
This code is throwing an ArgumentNullException at the specified line below and I don't
This is my code, which allocates space for a matrix of size specified by
What is the use of & operator in the code specified below. IS there
Refer below code public void acquire(){ synchronized(a){ print(acquire()); try{ //Thread.sleep(5000); synchronized(this){ wait(5000); } print(I
I have the below code, I am pinging a web address for a specified
So i have this code, the snippet is given below. list* init(list* list1) {

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.