Inversion of Controle container in Javascript