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

  • Home
  • SEARCH
  • 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 8720883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:07:45+00:00 2026-06-13T07:07:45+00:00

One interviewer asked me to explain what is this represented for in the following

  • 0

One interviewer asked me to explain what is this represented for in the following codes.
I had no idea about that.
Because I have not seen any codes like that before.
Please tell me is there any difference between these two and in what conditions such codes are useful?

function A(){
    this.x=1;//No.1
    function B(){
        this.y=2;//No.2
    }
}

I only know that when I use new to create a new object ,it has a property x equals to 1;

  • 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-13T07:07:46+00:00Added an answer on June 13, 2026 at 7:07 am

    That depends on how you call the function. If you call it as a regular function, like this:

    A();
    

    then this will be the window object of the document.

    If you use the function as an object constructor, like this:

    var a = new A();
    

    then this will be a reference to the newly created object.

    The reference this in the B function will never be anything, as it’s not possible to call the function. It’s local inside the A function and as there is no code in the A function that could be use to call the B function, it will never be called.

    If we make it possible to call the B function, the same thing applies as with the A function. What this is depends on how you use the function. Even if you call the B function from within the A function when the A function is used as a constructor (and thus this is an object reference in A), the B function doesn’t inherit this from A. It’s either a reference to window (when B is used as a function) or a reference to a newly created object (if B is used as a constructor).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today, an interviewer asked me this question. My immediate response was that we could
One of my friend was asked this question in an interview - You have
One of the interviewer had asked me the ways to filter dataview. I replied
I have recently had two telephone interviews where I've been asked about the differences
In interview, interviewer asked me one question that, What are the components to ensure
As some one mentioned in other forum that interviewer has asked the question given
I am aware that this is a very basic question, but an interviewer asked
In one interview, interviewer asked that what are Internal lists and External lists in
The following question was asked in one of my interview (few years back) What
This was the question asked in interview. Can we call one constructor from another

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.