Getting started with scripts in Bedrock edition?
Solution 1:
Go to the Minecraft site and scroll to the bottom and download the vanilla behaviour pack. Inside you will find documentation.
Note that JavaScript operates on a start at line 1 then work down (for the most part, while this isn't exactly true due to some stuff like functions being boosted but that's what matters) rather then having a main function. It doesn't need to execute inside of a function either, it just executes the first statement, then the next, the next, etc..