Error: shape(color) , Super Contructor

Prototypical Inheritance (50m) ==>> 3- Calling the Super Constructor (3:48)
](3- Calling the Super Constructor | Code with Mosh)

Mosh’s code will report error in chrome console,
“Uncaught ReferenceError:color is not defined” !!!

function Shape(color) {

this.color = color;

}

Shape.prototype.duplicate = function() {

console.log(‘duplicate’);

}

function Circle(radius) {

Shape.call(this, color);

this.radius = radius;

}

Circle.prototype = Object.create(Shape.prototype);

Circle.prototype.constructor = Circle;

Circle.prototype.draw = function() {

console.log(‘draw’);

}

const s = new Shape();

const c = new Circle(1, ‘red’);


Any other information I can provide, what I can do?

remove below line, it will be goooood:
Shape.call(this, color);

If you are using any script file and getting "Uncaught ReferenceError: ‘color’ is not defined " which means ‘color’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘color’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘color’.

To solve this error: Load the jQuery CDN library at the beginning of all your javascript files/scripts which uses $/ jQuery, so that $/jQuery can be identified in scripts .

There can be multiple other reasons for this issue:

  • Conflict with Other Libraries
  • Path to your library included is not correct
  • Llibrary file is corrupted
  • Working offline (when you use CDN)