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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:32:01+00:00 2026-06-02T04:32:01+00:00

I was expecting the obj to be instanceof F1 (‘this’ in ‘this.prop’ refers to

  • 0

I was expecting the obj to be instanceof F1 (‘this’ in ‘this.prop’ refers to F1 object in the code snippet below, similarly I thought ‘this’ in ‘return this’ of C1 refers to F1 which is not the case. It refers to Global Window object), but in actuality it is an instanceof Window. Why is that ? could you please explain ?

function F1() {
  this.prop = 5;
  function C1() {
   return this;
  }
  return C1();
}
var obj = new F1();
  • 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-02T04:32:04+00:00Added an answer on June 2, 2026 at 4:32 am

    if you are just creating an instance of F1, then just do this:

    function F1() {
      this.prop = 5;
    }
    var obj = new F1();
    

    you don’t need to return anything.


    the this inside C1 is not the same as this outside it. if you want to preserve this of the outside so that C1 can use it, store it into another variable

    function F1() {
    
        //preserve "this" from outside 
        var that = this;
    
        this.prop = 5;
    
        function C1() {
           return that; //"that" is "this" of the outside
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this dummy code below to test unnamed namespace. I have the following
I have the following JQUERY code that I'm expecting to return 3 json results
Possible Duplicate: How do I correctly clone a JavaScript object? I have this code:
I was expecting the following code to throw an exception when I goto write
I was expecting the below scenario common, but couldn't find much help online. I
I am expecting when I go $.each($(something).find(something), function(){ $(this).delay(1000).fadeOut(); }); then for each matching
My IDE is expecting a semicolon but I'm not sure where! It is this
The following code seems to execute the FileRetrieved event more than once. I thought
I have to dynamically call a list of methods on an object obj. I
When you have couple of synchronized blocks on an object (say) obj then how

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.