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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:10:25+00:00 2026-06-08T16:10:25+00:00

Func2 is called when I click on button . Why i don’t get any

  • 0

Func2 is called when I click on button . Why i don’t get any popup? Should I see both alert alert (“override1”) and alert (“override2”) after the first one?

// JavaScript Document
function person(name, surname) {
    this.name = "";
    this.surname = "";
    this.age = "11";
    this.setName(name);
    this.setSurname(surname);
    //alert('Person instantiated'); 
}
person.prototype.setName = function(name) {
    this.name = "Sir1" + name;
}
person.prototype.setSurname = function(surname) {
    this.surname = "-" + surname;
}
person.prototype.setAge = function(newAge) {
    this.age = newAge;
}
person.prototype.show = function() {
    alert("override1");
}
function employee(name, surname, company) {
    //if (arguments[0] === inheriting) return;
    person.call(this, name, surname); // -> override del costruttore
    //this.name = "Sir2"+name;
    this.company = company;
};
employee.prototype.show = function() {
    person.prototype.show;
    alert("override2");
}
function test2() {
    employee.prototype = new person();
    // correct the constructor pointer because it points to Person  
    employee.prototype.constructor = employee;
    // Crea un oggetto impiegato da persona
    impiegato = new employee("Antonio", "Di Maio", "Consuldimo");
    //impiegato.show();
    impiegato.show();
}​

Thanks

  • 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-08T16:10:26+00:00Added an answer on June 8, 2026 at 4:10 pm

    In test2() you’re replacing the entire employee.prototype with an instance of person, thus overwriting the employee.prototype.show function you’ve defined previously with the one inherited from person. Also, as stated in the answer by codebox, in employee.prototype.show() you’re not calling person.prototype.show(), but merely evaluating it in void context, which has no effect at all.

    You’ll have to set employee‘s parent before you define any additional methods on its prototype:

    employee.prototype = new person();
    employee.prototype.constructor = employee;
    employee.prototype.show = function() { ... }
    

    Also, when you call your parent’s method, you need to supply the correct context yourself:

    person.prototype.show.call(this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a clas called as MyFunctions that defines different functions func1 , func2
<button dojoType=dijit.form.Button id=continue1 onclick=funct1();timeTracker._recordEndTime(); timeTracker._track(pageTracker, undefined, 'test2');func2(); iconClass=dijitEditorIcon dijitEditorIconRedo type=button style=float:right> I am trying
I need to call some functions in sequence on form submit button click -
I have the following class which as you can see contains a EditText, Button
elemen.addEventListener('click',func,false); elemen.addEventListener('click',func,false); When elemen is clicked, will the function func be called twice, or
I have this code: class SomeClass: @classmethod def func1(cls,arg1): #---Do Something--- @classmethod def func2(cls,arg1):
In the js code specified below - var tclass = function(){ this.func2=function(){console.log('func2')}; this.b={ func1:
Suppose I have a line of code that starts like the following: Func1(Func2(Func3 Is
func($name1) should return name1 Is it possible?
Func<a, out b, bool> , just don't compile, how to declare that i want

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.