{"action":"created","issue":{"url":"https://api.github.com/repos/N-ZOO/everycode/issues/18","labels_url":"https://api.github.com/repos/N-ZOO/everycode/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/N-ZOO/everycode/issues/18/comments","events_url":"https://api.github.com/repos/N-ZOO/everycode/issues/18/events","html_url":"https://github.com/N-ZOO/everycode/issues/18","id":127384297,"number":18,"title":"[js]对象属性检索","user":{"login":"VaJoy","id":7721635,"avatar_url":"https://avatars.githubusercontent.com/u/7721635?v=3","gravatar_id":"","url":"https://api.github.com/users/VaJoy","html_url":"https://github.com/VaJoy","followers_url":"https://api.github.com/users/VaJoy/followers","following_url":"https://api.github.com/users/VaJoy/following{/other_user}","gists_url":"https://api.github.com/users/VaJoy/gists{/gist_id}","starred_url":"https://api.github.com/users/VaJoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VaJoy/subscriptions","organizations_url":"https://api.github.com/users/VaJoy/orgs","repos_url":"https://api.github.com/users/VaJoy/repos","events_url":"https://api.github.com/users/VaJoy/events{/privacy}","received_events_url":"https://api.github.com/users/VaJoy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/N-ZOO/everycode/labels/js","name":"js","color":"c7def8"},{"url":"https://api.github.com/repos/N-ZOO/everycode/labels/%E9%9A%BE%E5%BA%A6%E2%98%85%E2%98%85%E2%98%85","name":"难度★★★","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-19T07:41:00Z","updated_at":"2016-01-19T08:39:31Z","closed_at":null,"body":"判断对象是否存在某属性，若有则返回属性值，否则返回`undefined`\r\n- 示例：\r\n```js\r\n    var o = {\r\n      a : {\r\n        b : {\r\n          c : 11\r\n        }\r\n      },\r\n      b : 2\r\n    };\r\n    Object.prototype.hash = function(attr){\r\n      //TODO: 完成该方法\r\n    };\r\n    o.hash('a.b.c');  //11\r\n```"},"comment":{"url":"https://api.github.com/repos/N-ZOO/everycode/issues/comments/172776206","html_url":"https://github.com/N-ZOO/everycode/issues/18#issuecomment-172776206","issue_url":"https://api.github.com/repos/N-ZOO/everycode/issues/18","id":172776206,"user":{"login":"weiguoluck","id":9247733,"avatar_url":"https://avatars.githubusercontent.com/u/9247733?v=3","gravatar_id":"","url":"https://api.github.com/users/weiguoluck","html_url":"https://github.com/weiguoluck","followers_url":"https://api.github.com/users/weiguoluck/followers","following_url":"https://api.github.com/users/weiguoluck/following{/other_user}","gists_url":"https://api.github.com/users/weiguoluck/gists{/gist_id}","starred_url":"https://api.github.com/users/weiguoluck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weiguoluck/subscriptions","organizations_url":"https://api.github.com/users/weiguoluck/orgs","repos_url":"https://api.github.com/users/weiguoluck/repos","events_url":"https://api.github.com/users/weiguoluck/events{/privacy}","received_events_url":"https://api.github.com/users/weiguoluck/received_events","type":"User","site_admin":false},"created_at":"2016-01-19T08:39:31Z","updated_at":"2016-01-19T08:39:31Z","body":"<script>\t\r\n  var o = {\r\n      a : {\r\n        b : {\r\n          c : 11\r\n        },\r\n        c:{\r\n        \td:{\r\n        \t\te:22\r\n        \t}\r\n        }\r\n      },\r\n      b : 2\r\n    };\r\n    Object.prototype.hash = function(attr){\r\n      //TODO: 完成该方法\r\n      var attrList = attr.split('.');\r\n      var value = null;\r\n      var index = 0;\r\n      var length = attrList.length;\r\n      var getValue = function(obj,key){\r\n      \tif (index >= length) return;\r\n      \tif (obj[key]) {\r\n      \t\tvalue = obj[key];\r\n      \t\t++index;\r\n      \t\tgetValue(value,attrList[index])\r\n      \t\treturn;\r\n      \t}\r\n      \t\r\n      \tvalue = undefined;\r\n\r\n      \t\r\n      };\r\n      getValue(this,attrList[index])\r\n      return value;\r\n    };\r\n    console.log(o.hash('a.c.d.e'));  \r\n</script>"}}