{"action":"opened","issue":{"url":"https://api.github.com/repos/elevensky/myblog/issues/13","repository_url":"https://api.github.com/repos/elevensky/myblog","labels_url":"https://api.github.com/repos/elevensky/myblog/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/elevensky/myblog/issues/13/comments","events_url":"https://api.github.com/repos/elevensky/myblog/issues/13/events","html_url":"https://github.com/elevensky/myblog/issues/13","id":182691182,"number":13,"title":"about bind, call ,apply","user":{"login":"elevensky","id":6904834,"avatar_url":"https://avatars.githubusercontent.com/u/6904834?v=3","gravatar_id":"","url":"https://api.github.com/users/elevensky","html_url":"https://github.com/elevensky","followers_url":"https://api.github.com/users/elevensky/followers","following_url":"https://api.github.com/users/elevensky/following{/other_user}","gists_url":"https://api.github.com/users/elevensky/gists{/gist_id}","starred_url":"https://api.github.com/users/elevensky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elevensky/subscriptions","organizations_url":"https://api.github.com/users/elevensky/orgs","repos_url":"https://api.github.com/users/elevensky/repos","events_url":"https://api.github.com/users/elevensky/events{/privacy}","received_events_url":"https://api.github.com/users/elevensky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-13T04:07:24Z","updated_at":"2016-10-13T04:07:24Z","closed_at":null,"body":"- 来个栗子\r\n```js\r\nvar altwrite = document.write;  \r\naltwrite(\"hello\");  \r\n//1.以上代码有什么问题\r\n//2.正确操作是怎样的\r\n//3.bind()方法怎么实现\r\n```\r\n对于上面这道题目，答案并不是太难，主要考点就是this指向的问题，altwrite()函数改变this的指向global或window对象，导致执行时提示非法调用异常，正确的方案就是使用bind()方法：\r\n\r\n```js\r\naltwrite.bind(document)(\"hello\")  \r\naltwrite.call(document, \"hello\")  \r\n```"}}
{"actor":{"display_login":"elevensky"}}