3 ms·
Ask HN: What's the Running Time of Node's Array.push and Array.unshift?
I don't know C/C++ very well, but I'm trying to figure out where `Array.push` is implemented on the Node source code.
Is this one https://github.com/v8/v8/blob/master/src/builtins/builtins-array.cc#L145?
Ultimately, what I want to know if the runtime of the Array.push and Array.unshift implementation.
Based on the ECMA2019, It seems like push is O(1)
https://tc39.github.io/ecma262/#sec-array.prototype.push
and unshift is O(n)?
https://tc39.github.io/ecma262/#sec-array.prototype.unshift
- sergiaguilar 8y agodon't know
- sergiaguilar 8y agotrue
- sergiaguilar 8y agoyes
- skate22 8y agoI asked this to about 5 devs around 4 months ago and no one knew. I was surprised how hard it is to find the complexity for standard js functions