We can store global variables and functions inside a script library file in NetSuite. This helps to easily use a function or variable in multiple script records without defining the same for each record. For example, we can store global variables such as email addresses and commonly used functions inside a library file and access them from multiple scripts.
For this, we have to create the library file with global variables and functions and add the file to NetSuite File Cabinet. It is preferable to keep the library file and script files in the same folder for easy access and future updates.
In suitescript 1.0 we can specify the library file along with the script file while creating the script record. Select the library file after specifying the script file script type using the ‘Library Script File’ drop-down field. Refer to the screenshot shown here:

Now we can easily access the variables and functions inside the library directly using their names.
In SuiteScript 2.X, we don’t have the option to choose the library script file at the time of script record creation. In SuiteScript 2.X we have to import the library modules in each script file using the initial ‘define’ function.
e.g:
define([
'N/record',
'N/search',
'../Library/Library File.js'
],
function (
record,
search,
Library
) {......}
Now we can call any variable from the library file by typing the library name followed with a dot operator and variable/function name(eg: Library.var or Library.newFunction()).