/ Published in: JavaScript
URL: oojs
using prototype to add instance methods to a Class
Expand |
Embed | Plain Text
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()
You need to login to post a comment.
