After creating a custom JavaScript class, everything seemed to be working fine on Safari and Chrome in Mac OS. However, when I tried running it on my iPad, I encountered an error.
To pinpoint the issue, I started debugging through the Develop menu on Safari. What's puzzling is that I couldn't find any relevant information online about the specific error message I received: "Unexpected use of reserved word 'class'".
Below is a snippet of my JS code:
class LoadingIndicator{ // error stems from here
constructor(elementID){
this.tick = 8;
this.waitStatus = document.getElementById(elementID);
this.animateLoaderVar = setInterval(
this.animateLoader.bind(this),
10
)
}
animateLoader (){
if(this.tick == 8){
this.waitStatus.firstElementChild.innerHTML = ".";
}
else if(this.tick == 16){
this.waitStatus.firstElementChild.innerHTML = "..";
}else if(this.tick == 24){
this.waitStatus.firstElementChild.innerHTML = "...";
this.tick = 0;
}
this.tick += 1;
}
removeLoader(){
this.waitStatus.outerHTML = "";
delete this.waitStatus;
clearInterval(this.animateLoaderVar);
}
}