OOP functionality for javascript