/ Published in: JavaScript

using prototype to add instance methods to a Class
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function MyClass( name ) { this.name = name } MyClass.prototype.init = function() { alert( "I'm "+this.name ) } var a = new MyClass( 'A' ); var b = new MyClass( 'B' ) a.init() b.init()
URL: oojs
Comments
