This question already has answers here:
How to observe value changes in JS variables
                            
                                (3个答案)
                            
                    
                2年前关闭。
        

    

function getPercCalculated(x){
  return (x*9.3)/100;
}

var x = 10;
var perx = getPercCalculated(x);


取而代之的是,我想使用点运算符调用getPercCalculated

var perx = x.getPercCalculated()


有人能帮我吗..!!

最佳答案

Number.prototype.getPercCalculated= function(){
    return (this*9.3)/100;
};


这会将getPercCalculated附加到代码中的每个数字上

10-05 19:20