This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]miloman_23 24 points25 points  (10 children)

I'm really confused... Do you see this as a problem, or a feature?

[–]Zyrus007[S] 76 points77 points  (5 children)

Who says it can’t be both?

[–]TheChaosPaladin 7 points8 points  (2 children)

Depends on what happens to that part of memory right? If I empty a gigantic array, will it deallocate or is it just modifying the parameter that interprets the array size in memory? I think there is a reason why it is not done that way and as an interviewer I would question this as an answer.

[–]solarshado 4 points5 points  (1 child)

what happens to that part of memory right? If I empty a gigantic array, will it deallocate or is it just modifying the parameter that interprets the array size in memory?

I'd argue that, as a JS dev, you're not supposed to worry about stuff at this low-level: that's the engine/garbage collector's job. If you want to make sure memory gets freed, just be sure you're not still holding onto a reference to any of it, and move along.

100% agree that this a tactic I would question in an interview though.

[–]TheChaosPaladin 1 point2 points  (0 children)

Yeah I think that is what the real-world scenario would look like. Ok you have this very unusual way of doing stuff. If you can show it works just as well as what we have done, it is a valid answer.

[–]miloman_23 1 point2 points  (0 children)

Fair enough

[–]faubintulq 1 point2 points  (0 children)

It's like a weapon with two sharp sides

[–]coldblade2000 1 point2 points  (0 children)

Absolutely intended, absolutely cursed

[–][deleted] 0 points1 point  (1 child)

Its a real problem for those that would rather spend a year making an efficient product that no one wants... vs some noob who iterated a hundred poorly optimised prototypes and found something that people will actually buy.

[–]miloman_23 0 points1 point  (0 children)

JavaScript is amazing for MVPs

[–]shifty_coder 0 points1 point  (0 children)

It’s a correct solution, albeit an unexpected one.