In my javascript code, I'm using constants and while if works correctly in Chrome and Firefox, I get an undefined error in IE11. Emulation mode is set to agent string = Microsoft Edge. I read that in IE v5 - 9 (and 10 preview) constants are not available, but from 11 on it should be ok. What am I doing wrong and how to solve it? Check on browser type and if IE then just make variables for it? So I have a x.js file with this code:
const CONST_FAIL_1 = "something failed";
const CONST_FAIL_2 = "something else failed";
then, in my code I include the x.js file
<script language="Javascript" src="/scripts/x.js"></script>
and further down the page I have this javascript function:
function doSomething(x){
try{
if (ajaxCreateObjectinDB(x)){
return true;
}
else{
return false;
}
}
catch(err){
showErrorDiv(true, CONST_FAIL_1 + ":" + err.message);
return false;
}
}
I get the SCRIPT5009: 'CONST_FAIL_1' is undefined javascript error
Also, default for a function variable is not recognized. So:
function x(x,y=true){....}
gives me an error that the ')' is missing after 'y'.
Any input appreciated.