βItβs only work if somebody makes you do it.β β’ craft code β’ creative ideas β’ cutting edge β’ author β’ senior front end architect β’ professional scuba diver β’ adventures above and below the sea level
Location
Germany
Work
Senior Front End Architect, Full Stack Engineer, Creative Technologist and Scuba Diving Professional
Thank you for your contribution. I was going test the performance and compare both code snippets but upon closer inspection I think yours is only working on strings not array. Can you take a closer look?
βItβs only work if somebody makes you do it.β β’ craft code β’ creative ideas β’ cutting edge β’ author β’ senior front end architect β’ professional scuba diver β’ adventures above and below the sea level
Location
Germany
Work
Senior Front End Architect, Full Stack Engineer, Creative Technologist and Scuba Diving Professional
You have view with dynamic columns. You want to display all the data within the array evenly between these columns. As columns are added/removed you need to split the array.
Yes, you can definitely use css columns, but sometimes you just need things or flexible. Maybe it's not a column, but a grid. Or maybe you start with columns, but can divide them into grids (like in VSCode).
Another use case could be splitting up players into teams. If you have a group of players and you need to make equal teams, then you'll need to split that array.
Probably slower, but:
Thank you for your contribution. I was going test the performance and compare both code snippets but upon closer inspection I think yours is only working on strings not array. Can you take a closer look?
Thank you
Here's an array one:
Checked the benchmark (jsbench.github.io/#44d4426b04ed292...) and yours is way faster.
I updated the code and the article!
Thank you
Careful with this one though - mutation
Good spot. Definitely avoid this method unless you love bugs and impure functions π
I don't see any use case
You have view with dynamic columns. You want to display all the data within the array evenly between these columns. As columns are added/removed you need to split the array.
In my opinion, the alignment of columns is done in CSS.
Yes, you can definitely use css columns, but sometimes you just need things or flexible. Maybe it's not a column, but a grid. Or maybe you start with columns, but can divide them into grids (like in VSCode).
Another use case could be splitting up players into teams. If you have a group of players and you need to make equal teams, then you'll need to split that array.
far fetched...but OK, enough words for such an simple function....
You said you didn't see any use cases, I'm merely presenting them to you. Do what you will with it.