Sign in
Log inSign up

How to extend a javascript constructor?

Alex's photo
Alex
·Jun 28, 2018

Noob coming from php. I want to be able to extend a constructor and use its methods. The problem is when I do the following property values are being shared.

var Message = new Resource('message');
var Conversation = new Resource('conversation);

Conversation.limit = 5;
Message.limit = 8;

Conversation.getData() // pulls 8 items instead of 5

How do I create a method that returns a new constructor instead of an object?