JS to achieve the effect of multiple consecutive clicks( For example, the Android system can click the version number five times in a row to enable the effect of the developer option.)

Time:2021-6-8

**In the project, there is a need to click one button five times in a row. I thought that there should be a lot of such things on the Internet
Then I started Baidu. As a result, I found a lot of links. At that time, they were all the same (as if you transferred me and then I transferred him again). I began to copy and paste, and found that it didn’t work… Finally looked at the next code, found that there is a timer, think about it, this thing does not need to use a timer.
Finally, I have no choice but to write one by myself and post the code by the way, which may help others**

lastTime: number = 0;
count: number = 0;
maxCount: number = 5;
interval: number = 500;

const date = new Date()
if (date.getTime() - lastTime > interval) {
    this.lastTime = 0;
}
if (count === 0) {
  count++;
  lastTime = date.getTime();
  return
};
const currentInterval = date.getTime() - lastTime;
if (currentInterval < interval) {
  if (count > maxCount - 1) {
    Console. Log (` it's the fifth time ');
    this.count = 0;
    this.lastTime = 0;
    return
  };
  Console. Log (` under ${maxcount count}););
  this.count++;
  this.lastTime = date.getTime();
  return
};
this.count = 0;
this.lastTime = 0