Home › Forums › JavaScript › [Solved] Simpler way to write this snippet? › Reply To: Simpler way to write this snippet?
September 25, 2013 at 8:58 am
#151194
__
Participant
I’m somewhat confused about the updated syntax…specifically
this.then = this.then || 0;
We’re checking to see if then
is already defined before defining it: so, on the first use then
will be undefined, so that statement will assign the initial value 0
. Once we do then = now
, then
will have a value, and so that statement will leave it with its own value. It’s similar to doing:
if( ! this.then ){
this.then = 0;
}