how to access variable outside function in javascript