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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:32:04+00:00 2026-06-10T14:32:04+00:00

Can someone clear up what I’m doing wrong with my code? I’m a total

  • 0

Can someone clear up what I’m doing wrong with my code? I’m a total newb, simply trying to experiment with how to create objects, prototypes, and what the this command refers to in the context of prototypes. However, none of my code is working on jFiddle. I know this code is completely nonsensical, but I’m just trying to find out what the document prints in various cases to get a more concrete grasp of how objects, prototypes, constructors, and the “this” keyword works. But NOTHING is showing up at all!

function Person(identity) {
    this.identity = "fellow";
    this.logYou = function() {
        document.write('hi');
    };
};
Person.prototype.logMe = function() {
    document.write(this.identity);
};

var Dude = new Person("stud");

Person.logYou();  
Person.logMe();
Dude.logMe();

​

  • 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-10T14:32:06+00:00Added an answer on June 10, 2026 at 2:32 pm
    function Person() {
      this.identity = "fellow";
      this.logYou = function() {
        document.write('hi');
      };
    };
    

    When you call this.identity = "fellow"; the this keyword refers the context in which the function is running.
    So if you call the function in the Global scope, this refers to window object:

    Person();
    alert(window.identity); // fellow
    

    And if you instanciate the function, this keyword refers to the new object:

    var Dude = new Person();
    alert(Dude.identity); // fellow
    

    So the function Person has no property identity.
    If you want to have some property for your function:

    Person.identity = "fellow";
    alert(Person.identity); //  fellow
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hoping someone can clear this up for me. Let's say I have 2 globals:
Hoping that someone can help clear up this very annoying situation I find myself
I'm not clear on the status of XHTML - v1.0 versus v1.1. Can someone
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
Maybe someone can clear me up. I have been surfing on this a while
I'm probably tired for staring at this for too long, maybe someone can clear
Can someone give me a clear, concise definition of the difference between a programming
I haven't found a clear answer to this, so can someone help me? If
Can someone clarify my thinking on association fixup code in Entity Framework (T4 generated
Can someone explain in clear language how the non-zero lookbehind assertion (?<=.) technically works

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.