How to call a function within a function in Script Include

Sri63
Mega Expert

I want to call a function from a function in Script

funct_name_1: function(){

// Here i want to call funct_name_2

return ;
},

funct_name_2: function(){

   ........
   ........
return ;
}
1 ACCEPTED SOLUTION

ARG645
Tera Guru

this keyword is very important. 

funct_name_1: function(){

// Here i want to call funct_name_2
this.funct_name_2(object);//you can even pass parameters

return ;
},

funct_name_2: function(){

   ........
   ........
return ;
}

View solution in original post

6 REPLIES 6

ARG645
Tera Guru

this keyword is very important. 

funct_name_1: function(){

// Here i want to call funct_name_2
this.funct_name_2(object);//you can even pass parameters

return ;
},

funct_name_2: function(){

   ........
   ........
return ;
}

Kartik Magadum
Kilo Sage

Hello

We can call function in other function: Please refer given script

 

 

 function1: function() {
       return this.function2();
		
    },

    function2: function() {
        var first_name = 'name 1';
        var second_name = 'name 2';
        var full_name = first_name + ' ' + second_name;
        return full_name;
    },

 

 

You can test this script using Background Script: 

 

var si = new script_include_name().function1();
gs.info(si);

output: name1 name2

 

 

Thank You.!

Kartik Magadum