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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:04:28+00:00 2026-06-17T09:04:28+00:00

i written a simple javascript inheritance prototype, but i am getting issue.. any one

  • 0

i written a simple javascript inheritance prototype, but i am getting issue.. any one guide me the correct declaration?

code:

var Man = function(params){
  this.name = params.name,
  this.age = params.age,
  this.job = params.job;
}

Man.prototype.work = function(){
  return this.name +' is working as a ' + this.job;
}

var Women = function(params){
  this.name = params.name,
  this.age = params.age,
  this.job = params.job;
}

Women.prototype = new Man(); //assigning the prototype

var man1 = new Man({name:'man1',age:'age1',job:'job1'});
console.log(man1.work()); //it works

var woman1 = new Women({name:'woman1',age:'age2',job:'job2'});
console.log(woman1.work()); // it is not.. why?

the error i am getting :

TypeError: params is undefined
[Break On This Error]   

this.name = params.name,
  • 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-17T09:04:28+00:00Added an answer on June 17, 2026 at 9:04 am

    You’re not passing your parameters from the woman to the man, try this:

    Women.prototype = new Man({name:this.name,age:this.age,job:this.job});
    

    Actually, this would work also:

    Women.prototype = new Man(this);
    

    The advantage is that it’s just 4 letters of extra code, and this should work on all browsers that support JS.

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

Sidebar

Related Questions

I have written a simple javascript code to remove whitespace from a text box.
I have a problem with a very simple piece of code written in Javascript,
I've got a simple JavaScript regex check (written by other developer) that works perfectly
I've written some simple online games using purely HTML5 and JavaScript. Nothing fancy, no
I have written simple code to get content from xml file to php. $xml
I have written a simple memory game. You click on one of 16 cards
I've written a simple UDP server using Netty. The server listens on one port
I've written a simple web page that uses Javascript to control a Quicktime plugin
I'm having an interesting but difficult problem with my JavaScript code. Basically, I'm trying
I might have written a pretty confusing title but my question is rather simple.

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.