Javascript examples for Object:Constructor
Implement JavaScript inheritance, via Object.create vs new
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from ww w .j av a 2 s . co m*/ function my(){ this.publicProperty='SomeValue'; } my.prototype = { doThis : function(){}, doThat : function(){} } function MyClass(){} MyClass.prototype = Object.create(my.prototype); var obj=new MyClass(); console.log(obj.publicProperty); console.log(obj); }); </script> </head> <body> </body> </html>