/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var a = MyClass() a.name = "I'm A" a.init() var b = MyClass() b.name = "I'm B" b.init() alert( a.name+", "+b.name ) function MyClass() { var myObject = {} myObject.init = com_myclass_init myObject.name = "" return myObject } // simulate namespaces & avoid nesting object methods function com_myclass_init() { alert( this.name ) }
URL: oojs