gs.include() versus new ScriptInclude()

kungfuu72
Giga Expert

Came across a few examples where out-of-box code may reference gs.include('ScriptInclude');

But then what would be the difference (if any) in using

gs.include('ScriptInclude');

versus

var foo = new NewInclude();

I'm curious as to the differences and/or the advantages.

1 ACCEPTED SOLUTION

harikrish_v
Mega Guru

Hi Daniel,



gs.include() allows you to call a script include and use the functions in that script include within your current script include i.e you do not have to copy the functions into your current script include, but rather you can call them directly.



var foo = new NewInclude() initializes an object for the script include NewInclude. Now any function that you have defined within this script include class can be called directly using foo:-




eg:-




var NewInclude = Class.create();


NewInclude.prototype = {


  initialize : function() {


  },


      myFunction : function() {


          //do something


  },



  type : 'NewInclude'


};


Usage:-


var foo = new NewInclude();


foo.myFunction();


Thanks & Regards,


Hari




View solution in original post

5 REPLIES 5

The video in the above link is no longer available. Would you be able to re-share the link please?