Reputation: 161
I am studying a bit Angular docs and there's an assignment I do not really get.
setTimeout(() => this.seconds = () => this.timerComponent.seconds, 0);
Does it set a reference of this.timerComponent.seconds to this.seconds? Given that both seconds and timerComponent.seconds are methods, is it equivalent to the following?
setTimeout(() => { this.seconds = this.timerComponent.seconds }, 0);
Upvotes: 3
Views: 75
Reputation: 85767
It's equivalent to
setTimeout(() => { return this.seconds = (() => { return this.timerComponent.seconds; }); }, 0);
It passes a function to setTimeout
that, when called, assigns a function to this.seconds
that, when called, returns the current value of this.timerComponent.seconds
.
Upvotes: 3