DEV Community

Discussion on: Kyle Simpson proved I STILL don't know JavaScript (arrays)

Collapse
 
steffennilsen profile image
Steffen Nilsen

I haven't done any testing, but the part where you go over array instantiation and c++, I wonder how smart the V8 engine is when it comes to allocate memory for an array. I know that you shouldn't use sparse arrays, inserting items at indexes so there's a gap, but I can't recall if it does optimizations based on setting a predefined array size

Collapse
 
paceaux profile image
Paceaux

If I were smart enough to work on the V8 engine, I'd have it optimized based on array size.

Granted, I only ever took one C++ class... and I have liberal arts degrees. So I'm far from qualified-enough to say for sure if that's the right way to go.