The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

308036 (1) [Avatar] Offline
#1
According to Listing 7.15 using ES6/classes one can extend the class & use the super keyword to access the property of the base class, e.g.:
class Person {
 constructor(name) {
  this.name = name;
 }
}

class Ninja extends Person {
 constructor(name) {
  super(name);
 }
}

var ninja1 = new Ninja('Bob');  
// ninja1.name === 'Bob'


But I don't see corresponding pre-ES6 code for this in the book like for the other listings. Can someone please post what the corresponding pre-ES6 code is?
function Person(name) {
	this.name = name;
};

function Ninja() {};
Ninja.prototype = new Person();
Object.defineProperty(Ninja.prototype, 'constructor', {
	enumerable: false,
	value: Ninja,
	writable: true
});

var ninja1 = new Ninja('Bob'); 
// ninja1.name === undefined;