Created
April 6, 2017 20:47
-
-
Save a-eid/5329a33329609846168d3c77e1289a58 to your computer and use it in GitHub Desktop.
This file contains 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
function setObject(str , value){ | |
var arr = str.split('.') | |
var init = window | |
for(var i = 0 ; i < arr.length-1 ; i++){ | |
if(!init[arr[i]]) init[arr[i]] = {} | |
init = init[[arr[i]]] | |
} | |
init[arr[arr.length-1]] = value // trick .. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment