I am trying to execute some javascript with setInterval() method, below is my code
if(have_access){
let clock = setInterval(() => { // getting error here
clearInterval(clock);
clock = null;
document.getElementById('link_permissions').style.display = 'block';
}, 200);
}else{
let clock = setInterval(() => {
clearInterval(clock);
clock = null;
document.getElementById('link_permissions').style.display = 'none';
}, 200);
}
This code is working fine in Chrome and Firefox but getting Syntax error in IE11. What would be the work around to make this work in IE too.
Thanks in advance.
Like it was mentioned in the comments arrow functions are not supported in IE.
Simply change it to this:
if (have_access) {
let clock = setInterval(function() {
clearInterval(clock);
clock = null;
document.getElementById('link_permissions').style.display = 'block';
}, 200);
} else {
let clock = setInterval(function() {
clearInterval(clock);
clock = null;
document.getElementById('link_permissions').style.display = 'none';
}, 200);
}