Javascript examples for Object:Object Method
Using string methods to change DOM element parameters in Objects
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from w ww .java2s . com*/ function myClass(id) { this.em = document.getElementById(id); Object.defineProperty(this, 'html', { set: function(val) { console.log('Set to ' + val); } }); } (new myClass('foo')).html = 'bar'; }); </script> </head> <body> </body> </html>