I didn’t find any info in Macscripter but sharing Shane’s code from LNS forum:
https://forum.latenightsw.com/t/is-it-possible-to-call-javascript-from-applescript/291/3
I found this very handy
the ability to call Java Script functions from Applescript:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "OSAKit"
use scripting additions
property myJSLib : missing value
try
script "JSTest.scpt"
on error from jsLib
set jsLibPath to POSIX path of (jsLib as alias)
set {my myJSLib, theError} to current application's OSAScript's alloc()'s initWithContentsOfURL:(current application's |NSURL|'s fileURLWithPath:jsLibPath) |error|:(reference)
if myJSLib is missing value then error (theError's localizedDescription()) as text
end try
my callFunction:"doIt" withArgs:{2, 2} inJSLib:myJSLib
--> 4
on callFunction:funcName withArgs:argsList inJSLib:myJSLib
set {theResult, theError} to myJSLib's executeHandlerWithName:funcName arguments:argsList |error|:(reference)
if theResult is missing value then error (theError's localizedDescription()) as text
-- hack to convert from descriptor to correct AS class
return item 1 of ((current application's NSArray's arrayWithObject:theResult) as list)
end callFunction:withArgs:inJSLib: