I could see how adding more methods could be useful. Have you ever run into a real-world use case where you did this?
Adding data in this manner feels like it could be an anti-pattern. Developers expect arrays to work a certain way, and I'm having trouble coming up with a situation where it would be preferable to add data to a named property on an array instead of using a different variable. If you need to have related properties, you can store both the array and the properties within an object. But feel free to correct me if there's something I'm overlooking.
Regarding the use of the word quirk, I meant in comparison to the way arrays are treated in other languages.
There is a bizarre mindset around that says we shouldn't take advantage of more exotic features of a language because it won't be understood by some developers. If you follow that through to its logical conclusion, then we shouldn't write any code at all, and never advance our knowledge of a language and how it works.
I've never actually done it on an individual array, but I certainly wouldn't rule out doing it.
Bizarre or pragmatic? If you work in an organization where you're regularly making changes to code written by others, you need to be able to quickly and easily understand that code. Using tools that are appropriate for the situation goes a long way in making your code readable and maintainable.
I would need a strong justification to accept a code review where someone started adding named properties to arrays.
And please refrain from completely mischaracterizing my point. Obviously I'm not saying you shouldn't write code or learn things.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the feedback!
I could see how adding more methods could be useful. Have you ever run into a real-world use case where you did this?
Adding data in this manner feels like it could be an anti-pattern. Developers expect arrays to work a certain way, and I'm having trouble coming up with a situation where it would be preferable to add data to a named property on an array instead of using a different variable. If you need to have related properties, you can store both the array and the properties within an object. But feel free to correct me if there's something I'm overlooking.
Regarding the use of the word quirk, I meant in comparison to the way arrays are treated in other languages.
There is a bizarre mindset around that says we shouldn't take advantage of more exotic features of a language because it won't be understood by some developers. If you follow that through to its logical conclusion, then we shouldn't write any code at all, and never advance our knowledge of a language and how it works.
I've never actually done it on an individual array, but I certainly wouldn't rule out doing it.
Bizarre or pragmatic? If you work in an organization where you're regularly making changes to code written by others, you need to be able to quickly and easily understand that code. Using tools that are appropriate for the situation goes a long way in making your code readable and maintainable.
I would need a strong justification to accept a code review where someone started adding named properties to arrays.
And please refrain from completely mischaracterizing my point. Obviously I'm not saying you shouldn't write code or learn things.