Y
Hacker News
new
|
ask
|
show
|
jobs
by
aquarion
4766 days ago
Because Math.random's expensive and you don't want to execute it unless you're sure.
2 comments
drharris
4766 days ago
Expensive only really matters in a loop. And this logical operator would short circuit anyway.
link
masklinn
4766 days ago
The && operator short-circuits, if `!_ok` Math.random won't be called at all.
link