Skip to content

Instantly share code, notes, and snippets.

@antyakushev
Last active August 29, 2015 14:01
Show Gist options
  • Save antyakushev/7937f3c86500217e67d7 to your computer and use it in GitHub Desktop.
Save antyakushev/7937f3c86500217e67d7 to your computer and use it in GitHub Desktop.
//Напишите на JavaScript код, превращающий строку 'a.b.c.d' в объект {a: {b: {c: 'd'}}}
function pto(path) {
var p=path.split('.'),o=p.pop(),c,k;
while (k = p.pop()) {c={};c[k]=o;o=c;}
return o
}
// Sergey Chikuyonok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment