var a = { test: { debug: "123" }}; var inp = 'a.test.debug'; var obj = window; for(var i = 0, inp = inp.split('.'); i < inp.length; i++) { obj = obj[inp[i]]; } console.log(obj)