Skip to main content

All Questions

1 vote
1 answer
354 views

ES6 - Where is it better to initialize a member - parent class or derived class?

I am trying to figure out if there is a better practice for initializing class members of derived classes in ES6 - in the child or the parent, and why? For example: Option 1: class AbstractAnimal {...
Yogev's user avatar
  • 23
3 votes
1 answer
340 views

Is it bad to access the constructor prototype within the constructor?

Most places where I have seen prototypes defined for a constructor it was done like so. var Person = function(){ this.stuff = stuff; } Person.prototype.doSomething = function(){console.log("...
Supetorus's user avatar
0 votes
0 answers
1k views

validating arguments in javascript constructors

In many cases, it is useful to have a constructor or factory method that validates arguments before instantiating an object, returning a new object if the arguments are valid and null otherwise. But ...
fearless_fool's user avatar
2 votes
1 answer
1k views

Why does JavaScript console.log of objects sometimes show prototype/constructor pattern forever

I've always noticed this, but never actually understood what's happening here. I have a fairly simple object that I've put in a console.log. It has a seemingly never ending pattern of prototype -> ...
Goose's user avatar
  • 1,908