Greetings,
After reading the following article I have a question:
https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript
In the inheritance example, the Person constructor doesn’t take any parameters. How would this same example look if I were to add one and call it from the Student constructor?
Thanks!
Well, a way that you can re-use the logic of the
Personconstructor is invoking it withcallorapply, for example:If you want to prevent the execution of the
Personconstructor when is called without arguments (like in the line:Student.prototype = new Person();), you can detect it, e.g.: