Frage im Vorstellungsgespräch bei Bitovi

Who do you simulate Java-type inheritance in JavaScript? Draw some Visio diagrams to explain it.

Antworten zu Vorstellungsgespräch

Anonym

23. Dez. 2015

The right answer is to take the parent constructor (let's say it's called parent) and call it in the child and then set the child's prototype equal to parent. function child(){ parent.apply(this, arguments); } child.prototype=parent;

2

Anonym

17. Mai 2017

Or you could have done both concepts in the constructor. function Parent(name){this.name = name;} function Child(name){ Parent.call(this, name); this.__proto__ = Parent.prototype; }