Javascript examples for Object:Object Method
Implement getter and setter on object
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w w w.jav a 2s. c om*/ var Application = function(){ this.local = {}; }; Application.prototype.Value = function(){ if (arguments.length) { this.local.result = arguments[0]; }else{ return this.local.result; } }; var app = new Application(); app.Value(6); console.log(app.Value()); } </script> </head> <body> </body> </html>