How to write enclosed functions with JavaScript without using that for this