var lastLoopRun = 0; if (new Date().getTime() - lastLoopRun > 40) { Какое-то действие; } I would like to know what this line does in the if condition? Thanks in advance for the answer :)
var lastLoopRun = 0; if (new Date().getTime() - lastLoopRun > 40) { Какое-то действие; } I would like to know what this line does in the if condition? Thanks in advance for the answer :)
A new instance of the Date class (read: new Date) indicates the current date and time (set on the user's computer). The getTime () method allows you to get the number of milliseconds that have elapsed since January 1, 1970 (this is called the timestamp). It turns out that in your example, the if condition checks whether the difference in the number of milliseconds that have passed since January 1, 1970, and the value of the lastLoopRun variable is greater than 40
Source: https://ru.stackoverflow.com/questions/737300/
All Articles
ifconstruction means that if time is more than 40, it means that we are doing something. - And