<script> var obj = { users: { name: 'max' } } var s = 'users.name' function getName(ob) { with(ob) { var p = eval(s) return p } } alert(getName(obj)) </script>