support different types of function definition in javascript