Ahuahu
Ahuahu

Reputation: 55

How to use multiple function name together?

I have function but my script using different name by the function name. So, i want to use the function with or condition. Whats the rules?

function myfunction1 || myfunction2 (param){
  //some code
}

Update

var myfunction2 = myfunction1;
function myfunction1(param) {
    //some code
}

function myfunction1(param) {
    //some code
}
var myfunction2 = myfunction1;

whats the var implement rule? var should be before or after or both will work in jq/js?

Upvotes: 0

Views: 1148

Answers (1)

Vit Stukalov
Vit Stukalov

Reputation: 42

I recommend you add a variable that points to the original function. In that way, you can call myfunction1 or myfunction2 interchangeably. They will act the same.

function myfunction1(param) {
    //some code
}
var myfunction2 = myfunction1;

Upvotes: 1

Related Questions