Reputation: 23
This is my first project using javascript. I am developing a set of scripts in order to acquire multiple types of data in the same area scope in google earth engine. In doing this, I could make large script to do this but would rather call functions from other scripts. I have tried multiple solutions to do this, though they were a while ago and I, unfortunately, have lost them to time. One of the primary issues that I have run into is most of the javascript help I have seen is for use in web pages not backend development.
Any questions about this are welcome and would like to learn how to make better questions if you have constructive criticism?
Upvotes: 1
Views: 2025
Reputation: 4603
This is possible using the require
function. In short, write a code file with anything you wish to export named as an "exports" variable, e.g.
exports.scale = 30;
Then save it and remember where it is.
Load it in another script using require
, like this:
var constants = require('users/me/that_script.js');
And refer to the exported variable using constants.scale
.
Upvotes: 2