diff --git a/packages/core/src/render3/PERF_NOTES.md b/packages/core/src/render3/PERF_NOTES.md index d031899025..9a75641e00 100644 --- a/packages/core/src/render3/PERF_NOTES.md +++ b/packages/core/src/render3/PERF_NOTES.md @@ -64,3 +64,10 @@ for (var i = 0, keys = Object.keys(obj); i < keys.length; i++) { const key = keys[i]; } ``` + +## Recursive functions +Avoid recursive functions when possible because they cannot be inlined. + +## Loops +Don't use foreach, it can cause megamorphic function calls (depending on the browser) and function allocations. +It is [a lot slower than regular `for` loops](https://jsperf.com/for-vs-foreach-misko)