Last active
August 29, 2015 14:26
-
-
Save micmmakarov/1fbdb64adfbb1c54aa00 to your computer and use it in GitHub Desktop.
Recursive function to change hash by deep_path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sonar.changeByArray = (hash, array, newValue) -> | |
obj = hash | |
i = 0 | |
while i < array.length - 1 | |
obj = obj[array[i++]] | |
obj[array[i]] = newValue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment