'This.' - Don't understand why it's used?

Does anyone know what the purpose of ‘this.’ before the intervalID in startInterval() is?
And also why does setInterval() get called during a variable declaration?

Thanks!

this refers to the current instance of the class. So, if you have multiple instances of the class Clock, and each has a different intervalID, then using this refers to whichever instance it is being used for, not a generic value.

2 Likes