DEV Community

Discussion on: 5 Programming Patterns I Like

 
idanarye profile image
Idan Arye

O(n2), not O(n2). As in - O(n*n). As the array get bigger, the spread operator takes more and more time to perform because it needs to copy more values, as opposed to push which only needs to add one value (and sometimes increase the size, which takes longer - but it doesn't do it on each push)

Thread Thread
 
adamgerthel profile image
Adam Gerthel

O(n2), not O(n2). As in - O(n*n)

I'm aware, I just don't know how to do it on my keyboard. And yes, I do realise there's a major difference and it shouldn't be trivialised..

Anyway, thanks - I learned something new today :)

Thread Thread
 
idanarye profile image
Idan Arye

dev.to does it for you with the ^ operator - so O(n^2) becomes O(n2).