I am trying to import one function declared in a javascript file into another javascript file, but can't get it right. I am not using any transpiler.
I am trying to import variables and functions from one JavaScript file to another but don't want to use Transpilers. I can't get it right how to import and export functions. I am using Adobe{Brackets}
as my IDE.
I have already converted the importing script to a module, but still I am unable to export or import. As a second try, I tried converting exporting script to a module but still get the following error:
Parsing Error- Export and import keyword are reserved.
As a third try, I converted both files to a module. Still it does not work.
HTML:
<html>
<head><title>Test1</title>
</head>
<body>
<button type = "button" class= "slctbtn" onclick= "select()" id= "selct_btn">Select</button>
</body>
<script src="javascript/select.js"></script>
<script type="module" src="javascript/Test.js"></script>
</html>
javascript/Test.js:
var today = 28;
export {today};
javascript/select.js:
import {today} from "./javascript/Test.js";
function select(){
var month = "august";
var year = "2019";
alert("this is " + month + " of the year " + year + " and today is " + today + " day.");
}
Expected Result: Alert must show text like this image