Javascript JS在prototype中使用prototype函数

Javascript JS在prototype中使用prototype函数,javascript,Javascript,嘿,我在写一个小东西: function Point(x, y) { this.x = x; this.y = y; this.angle = Math.sqrt(x * x + y * y); this.radius = Math.atan(y / x); }; Point.prototype = { constructor: Point, calculateRadius: function(x, y) { return Math

嘿,我在写一个小东西:

function Point(x, y) {
    this.x = x;
    this.y = y;
    this.angle = Math.sqrt(x * x + y * y);
    this.radius = Math.atan(y / x);
};
Point.prototype = {
    constructor: Point,
    calculateRadius: function(x, y) {
        return Math.sqrt(x * x + y * y);
    },
    calculateAngle: function(x, y) {
        return Math.atan(y / x);
    },
    cartToRad: function(x, y) {
        this.radius = calculateRadius(x, y);
        this.angle = calculateAngle(x, y);
    }
};
var coords = new Point(0, 0);
coords.cartToRad(5, 0.523);
这会抛出一个错误:

ReferenceError:未定义计算器半径。

是否可以在其他原型函数中使用原型函数?

您需要将它们作为
的属性引用,就像任何其他属性一样