Is there a way to import an object from another javascript script

I have a JavaScript object which I want to work with on another JavaScript script, is there a way to import it? So far I’ve tried this code:

import { object } from './mainscript.js';

And it doesn’t work.