Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
aquarion
· 13y ago · 0 comments
Because Math.random's expensive and you don't want to execute it unless you're sure.
Comments
[–]
drharris
13y ago
Expensive only really matters in a loop. And this logical operator would short circuit anyway.
[–]
masklinn
13y ago
The && operator short-circuits, if `!_ok` Math.random won't be called at all.