Mariusz Najwer’s Post

‘F’ in JavaScript stands for fun! 🎉 🪩 Time complexity looks good on paper. But small language details can slow your code a lot. Big O notation says s[j] and s.charCodeAt(j) are both O(1). But in reality, s.charCodeAt(j) returns a small number that the JS engine caches with no need to allocate new memory. Meanwhile, s[j] creates a new String object every time, using up memory and slowing your code. A few milliseconds, but it hurts terribly in performance tests. #interview #javascript #node

  • text

To view or add a comment, sign in

Explore content categories