I've got a module called utilities in a utilities.js file. I am using it for some basic js functions and I want to hide the module from the global namespace. I understand that to do this I should create a module, export it, import it in the needed file, then invoke its functions. However, I cannot seem to properly export the module. I figure this is pretty simple but everything I have tried gives an error. Here is my code:
var utilities = (function(){
return {
debounce: function(func, wait, immediate){
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
}
})();
export { utilities };
My error:
application.js:12560 Uncaught SyntaxError: Unexpected token export