Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array.remove() should mutate the existing array and return the mutated array #28

Closed
El-Dringo-Brannde opened this issue Aug 14, 2018 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@El-Dringo-Brannde
Copy link
Owner

Currently,

the only way to mutate the array is to re-reference itself such as..

let arr = [1,2,3,4]


arr = arr.remove(2)
console.log(arr)
// => [1,3,4]

A change should be made such that it still returns the new value of the array, but also mutates the original array.

For example,

let arr = [1,2,3,4]


arr.remove(2)
console.log(arr)
// => [1,3,4]
@El-Dringo-Brannde El-Dringo-Brannde added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Aug 14, 2018
@decarbonite
Copy link
Contributor

May I work on this issue? :)

@El-Dringo-Brannde
Copy link
Owner Author

@decarbonite feel free my friend, along with anything else you may want to work on in the project

@decarbonite
Copy link
Contributor

decarbonite commented Aug 23, 2018

Thank you.
I have two approaches in mind for this issue, using _.remove from lodash but i have to name it something else so it doesnt crash the program cuz it has the same name as the main function. Or using splice to mutate the array. Which one would more suitable?

@El-Dringo-Brannde
Copy link
Owner Author

I'd like splice personally, it avoids importing another section of lodash code which inflates the package size. As opposed to slice which is I think can be a lot smaller, I'd need to look at the lodash remove function though

@El-Dringo-Brannde
Copy link
Owner Author

Closed with #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants