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

Expensive only really matters in a loop. And this logical operator would short circuit anyway.
The && operator short-circuits, if `!_ok` Math.random won't be called at all.