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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:45:08+00:00 2026-05-18T21:45:08+00:00

function myFunction(message) { this.message = message; return this.message; } document.body.innerHTML = new myFunction(Hello); I

  • 0
function myFunction(message)
{
this.message = message;
return this.message;
}

document.body.innerHTML = new myFunction("Hello");

I learnt that “in JavaScript this always refers to the ‘owner’ of the function we’re executing, or rather, to the object that a function is a method of.” reference

In this example it would seem that the this in myFunction should refer to the owner of the myFunction then, the window. It seems like it’s referring to the myFunction though. Why is this?

  • 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-18T21:45:08+00:00Added an answer on May 18, 2026 at 9:45 pm

    When you use the new operator, you create a new instance of an object defined in the constructor function and this refers to the new object.

    Old answer before the question was completely changed by the addition of the new keyword:

    Since myFunction is not being called with the new keyword, or in the explicit context of another object, it is effectively: document.body.innerHTML = window.myFunction("Hello");

    So this is the window object.

    You can confirm this by editing the function to console.log whatever this is and then looking in Firebug.

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

Sidebar

Related Questions

In a continuation from this question . I'm trying to bind a given function
I'm triying to make a function that add a 'where' clause to a query
This is my function to calculate the gcd of two numbers a and b
I have an SQL Function that takes a String, a DATE and another string.
I have a function, that gets a large XML file, then parses it, and
I have this: case true: echo '<textarea rows=2 cols=35 name=message_friend id=message_friend></textarea>'; break; default: echo
OK, so I have this tiny little corner of my code where I'd like
i am working on a fishing app these days and i am getting a
I'm using PHP to send an attachment in an email, all works as expected

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.