pathTo can be called with the global object to get the path to the script.
app = Application.currentApplication()
app.includeStandardAdditions = true
pathToScript = app.pathTo(this)
app = Application.currentApplication()
app.includeStandardAdditions = true
// Turn off parameter type checking
app.strictParameterType = false
// Run script text
scriptText = 'Application("Mail").activate()'
app.runScript(scriptText, { in: '_javascript_' })
// Run a saved script
// Build a path to a script using Standard Additions
pathString = app.pathTo('desktop') + '/foo.scpt'
// ...or build a path to a script using Objective-C
pathString = $('~/Desktop/foo.scpt').stringByExpandingTildeInPath.js
pathObject = Path(pathString)
app.runScript(pathObject)