I have a question about my post: Dynamic way to use string/array as index of object in javascript

I see that my first attempt at this question was outside the scope of what I should ask at Code Review, as the solution I offered was not working for purpose, and what the code needed to do was not clearly explained. I have edited the question a lot, now including a solution that is fit for purpose and explained more clearly what it is needed to do. From reading help-reopen-questions it seems that after commenting that the question has been improved (which I've done), the next step is to ask a question here? Is there a problem with the question as it currently stands for Code Review?


1 Answer 1


Thank you for revising the question — Rev 5 is much better as a Code Review question than the original.

That said, I hesitate to reopen it, because I'm not 100% sure I understand what you are trying to accomplish with this code. Why are you calling the function as change_object_using_path_string("example_object", …) rather than change_object_using_path_string(example_object, …)? The former basically forces you to use the eval(), which you are trying to avoid.

As stated in the Help Center, Code Review requires real code from a project. Anytime you simplify or obfuscate the code before posting it for review, it creates a bit of uncertainty about what the code is for, and makes it harder to give you solid advice.

  • \$\begingroup\$ Thanks for your answer - A solution that involves inputting example_object directly rather than as string "example_object" would be better, but I haven't worked out a solution that doesn't involve eval to achieve what I want (i.e. change the value at the indexed position of the object with the new value). That's the only reason why I'm inputting the object name as a string. I've edited the question to reflect this. As for using real code - the function is real, I was trying to use examples for the inputs as the inputs are dynamic. \$\endgroup\$
    – BeepBop
    Jan 17, 2018 at 9:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .