Implementing "new" operator in Js