JavaScript sees no class method



  • There's a code like this:

    function Ball(param) {
        this._radius = param.radius;
        this._color = param.color;
    }
    

    Ball.protorype = {
    constructor: Ball,

    INCREMENTATION_STEP: 5,
    
    draw: function () {
        console.log("ball drawn with radius:" + this._radius + " and color: " + this._color);
    },
    inc: function () {
        this._radius += this.INCREMENTATION_STEP;
    }
    

    }

    bb = new Ball({
    radius: 100,
    color: "red"
    });
    bb.draw();

    He doesn't see the method to draw and write:

    bb.draw is not a function.

    What do we do?



  • There's no such key word for proto-Rip. There's a prototype.

    Ball.protorype = {
    

    After the correction, it all worked.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2