Function.prototype.returnValue

<script type="text/javascript">

function topla() {
this.a = 3;
this.b=5;


return  this.a + this.b;
}

alert(topla());// 8;



Function.prototype.returnValue = function(){



}


alert(topla.returnValue()); //  message box displays undefined. I want, message box will display 8. How can I do this?




</script>

alert([b]topla.returnValue/b); // message box displays undefined. I want, message box will display 8. How can I do this?

Not sure what you’re trying to do, but this might help:

var Topla = function(){};

Topla.prototype.returnValue = function(){
  this.a = 3;
  this.b = 5;
  return  this.a + this.b;
};

var t = new Topla();
alert(t.returnValue());

Also, don’t modify objects you don’t own:

Function.prototype.returnValue = function(){}

is bad, M’kay?

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.