Using Context in JavaScript to achieve cleaner code