Importing server script libraries

You can import a server script library into JavaScript using the import statement.

Use the following JavaScript statement to import server library code into the current code:

import libraryName;
Note: You cannot use import to insert client library code.

For example, if you have a library named PrintUtil with the following content:

// Function for highlighting output to log
function printToLog(stuff) {
  print("\r\nPRINT START\r\n");
  print(stuff);
  print("\r\nPRINT END\r\n");
}

You might call the printToLog function as follows:

import PrintUtil;
printToLog("Here's some stuff for the log.");