, , . C++, , JavaScript . , ┬л┬╗ . , Circle JavaScript, - :
function Circle(radius){
this.radius = radius;
}
Circle.prototype.getDiameter = function(){
return 2*this.radius;
};
var circle = new Circle(2);
alert(circle.getDiameter());
Circle Circle.prototype, - JavaScript. , , . , . , - , тАж
Circle.prototype.getDiameter = function(){
return -5;
};
тАж , , . , , ( ┬л┬╗) JavaScript . - тАж
Number.prototype.valueOf = function(){return 42;};
тАж , Number, , , , :
alert((0).valueOf());
alert((1).valueOf());
alert((NaN).valueOf());
, , , JavaScript , . , - - JavaScript , , . , ┬л JavaScript┬╗ .