- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Performance Basics
JavaScript Performance
JavaScript Performance Basics
Fast code starts with measuring, not guessing where the slow part is.
Intuition about what is slow is wrong surprisingly often.
The next lessons cover specific techniques; this one covers the mindset.
Example
Example
javascript
const started = Date.now();
let total = 0;
for (let i = 0; i < 100000; i++) {
total += i;
}
const elapsed = Date.now() - started;
console.log(elapsed >= 0);
console.log(typeof elapsed);