\$\begingroup\$Really good! I was thinking of something like a pop(), but couldn't come an algorithm similar to your's.\$\endgroup\$
– thadeuszlayApr 11 at 18:53

\$\begingroup\$When would you use object.freeze?\$\endgroup\$
– thadeuszlayApr 12 at 12:16

\$\begingroup\$Here, everything is local and easy to understand, so freezing introduces noise, mostly. If you need to pass it to other people's code, or the project grows so large that there is a possibility of interacting with other people's code, then I would see value in freezing. That's my opinion.\$\endgroup\$
– 200_successApr 12 at 14:02

I'm not very good at Javascript, but I do know how to make an algorithm.

In the code below I use the fact that correct {} or [] or () will always touch and can be removed. Just taken these away until there aren't any left and if you've got an empty string it was balanced, if it is not empty then clearly it must be unbalanced.