In trying to avoid division by 0, a common alternative is to check if the divisor is 0 and if so then the result becomes 0 (with error logging taking place elsewhere).
Comparing performance of: IF Logic vs Ternary Logic vs AND Logic
Memory measurements supported only in Chrome.
For precise memory measurements Chrome must be launched with --enable-precise-memory-info flag.
More information: Monitoring JavaScript Memory