JavaScript function modulation