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

duplicateObject and deepDuplicateObject #29

Open
CMEONE opened this issue Oct 31, 2021 · 3 comments · May be fixed by #34
Open

duplicateObject and deepDuplicateObject #29

CMEONE opened this issue Oct 31, 2021 · 3 comments · May be fixed by #34
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@CMEONE
Copy link
Member

CMEONE commented Oct 31, 2021

We should have a method that duplicates an object, like this:

helpful.duplicateObject({"a": 1, "b": 2}) => {"a": 1, "b": 2}

You must use a for loop for this method to copy over all the keys and their corresponding values to the new object.

We should also have a method that duplicates an object and all inner objects, like this:

helpful.deepDuplicateObject({"a": 1, "b": 2, "c": {"d": 4, "e": 5}}) =>{"a": 1, "b": 2, "c": {"d": 4, "e": 5}}

We encourage using the duplicateObject method and recursion to create the deepDuplicateObject method.

@CMEONE CMEONE added enhancement New feature or request good first issue Good for newcomers labels Oct 31, 2021
@CMEONE
Copy link
Member Author

CMEONE commented Nov 13, 2021

@TheSoniix The details for the duplicateObject and deepDuplicateObject methods are above. Please respond to this issue so that I can assign it to you (GitHub unfortunately does not allow me to assign an issue if you have not replied on that issue). Thanks for your contributions!

@TheSoniix
Copy link

Hello :)

@TheSoniix
Copy link

Hello,

Sorry for the long break. Unfortunately I had a lot to do at the university.
I have written two recursive functions that deeply clone arrays and objects.
It works with the datatypes: null, undefiend, string, number, boolean, object, Date and array.
There is only one problem:

  • Functions of objects are not passed

I think it's totally fine to point out this case in the documentation, so that the users use this functions correctly.

What is your opinion about that? @CMEONE

@CMEONE CMEONE linked a pull request Dec 17, 2021 that will close this issue
15 tasks
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants