{"action":"created","comment":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/60168873","id":60168873,"diff_hunk":"@@ -1,87 +1,86 @@\n * 原文链接 : [Leveling Up Your JavaScript](http://developer.telerik.com/featured/leveling-up-your-javascript/)\n * 原文作者 : [Raymond Camden](http://developer.telerik.com/author/rcamden/)\n * 译文出自 : [掘金翻译计划](https://github.com/xitu/gold-miner)\n-* 译者 : \n+* 译者 : [Hikerpig](https://github.com/hikerpig)\n * 校对者:\n-* 状态 : 待认领\n \n \n-JavaScript is one of those languages that can be easy to pick up, it can be infinitely more difficult to master. However, a lot of articles seem to assume that you are already a master.\n+JavaScript 是一门入门容易，但是相当难以精通的语言。可现今一些文章总假设你已经精通了它。\n \n-I’ve been using JavaScript since its introduction as LiveScript in 1995, but slowly moved away from client-side development to retreat into the safe confines of the server. For the past five years, I’ve refocused on the client-side. I’m happy to find that browsers are far more competent, powerful, and easier to debug than they were in the early days. But JavaScript has grown in complexity and is not any easier to master. Recently I came to a conclusion. I don’t necessarily need to _master_ JavaScript – but I can get better. I am happy being a “good” JavaScript developer.\n+我从1995年JavaScript 还以LiveScript 名字出现的时候就开始用它了，但后来逐渐从前端开发撤回服务器的安全怀抱中，直到五年前才重拾。很高兴看到如今的浏览器更加的强大和易于调试。但JavaScript 已经演变得越来越复杂。不过最近我终于得出结论，我并不需要_精通_Javascript，只需要比以前更进一步就好。能成为一个\"好\"的JavaScript 开发者我便觉欣慰。\n \n-What follows are the tips and techniques that I have found to be useful and – most of all – _practical_ in terms of writing JavaScript: [organizing code](http://developer.telerik.com/featured/leveling-up-your-javascript/#organization); [linting](http://developer.telerik.com/featured/leveling-up-your-javascript/#linting); [testing](http://developer.telerik.com/featured/leveling-up-your-javascript/#testing); and [using browser developer tools](http://developer.telerik.com/featured/leveling-up-your-javascript/#devtools). While some of these may seem obvious to experienced JavaScript developers, it’s very easy to fall into bad habits when you are new to a language. These guidelines have helped me level up my skills and produce better experiences for my users. And _that’s_ our number one goal, right?\n+以下是我发现的一些_实用_的JavaScript 小技巧: [组织代码](http://developer.telerik.com/featured/leveling-up-your-javascript/#organization); [代码风格检验](http://developer.telerik.com/featured/leveling-up-your-javascript/#linting); [测试](http://developer.telerik.com/featured/leveling-up-your-javascript/#testing); 以及 [使用开发者工具](http://developer.telerik.com/featured/leveling-up-your-javascript/#devtools)。里面有几条对有经验的JavaScript 开发者来说可能很显而易见，但是语言初学者来很容易养成坏习惯。这些技巧提高了我的技术水平，同时也为我的用户创造了更好的体验。_这_难道不是我们最大的目标么。\n \n-> You can download the source code for the examples in this [article here](http://developer.telerik.com/wp-content/uploads/2016/01/code.zip).\n+> 你可在此处[下载](http://developer.telerik.com/wp-content/uploads/2016/01/code.zip)本文的样例代码。\n \n-## Organization\n+## 组织代码\n \n-As a new JavaScript developer begins learning their craft, they will inevitably begin with a large block of code on top of their HTML page. It always starts simple. A simple bit of jQuery to autofocus a form field. Then maybe form validation. Then a little dialog widget that marketing just loves – you know, the ones that stop people from reading content so that they can Facebook Like the site itself. After a few iterations of this you’ve got a few hundred lines of JavaScript within an HTML file that probably has a few hundred lines of tags.\n+JavaScript 初学者总是不可避免地在他们的HTML 页面里写上一大坨代码。开始的时候都是很简单的，例如使用jQuery 给一个表单输入自动加上焦点，然后要加上表单验证，然后又要加上一些市场上走俏的模态框组件-就是那些阻止用户往下阅读内容好让他们在Facebook 上给网站点赞的东西。经过这些七七八八的功能迭代后你的一个文件里HTML 标签和JavaScript 都有了几百行。\n \n-It’s a mess. Stop doing it. It sounds simple, and I’m almost embarrassed to even write it down as a tip, but it is _very_ tempting to just whip up a quick script block on top of your page. Avoid that temptation like the plague please. Make it a habit when you create a new web site to go ahead and create an empty JavaScript file. Include it via the script tag and it will be ready for you when you begin adding interactivity and other client-side features.\n+别再继续这种乱七八糟的方式了。这个技巧太简单了我都不好意思单独把它列出来，但大家还_真的_很难拒绝这种把代码一坨扔上页面的偷懒做法。但请各位务必避之如瘟疫。新写网站时，请新建JavaScript 文件书写交互以及各种客户端功能的代码，然后用script 标签加载它，请养成这个好习惯。\n \n-Once you’ve gotten off the HTML page (doesn’t that feel cleaner?), the next problem you’ll run into is organization of the code itself. Those few hundred lines of JavaScript may work just fine, but the first time you have to debug or modify the code after a few months away you may find yourself wondering just where in the heck a particular function exists.\n+把JavaScript 从HTML 页面中剥离以后（干净多了是不是？），下一个问题就是关于这些代码的组织形式了。这几百行JavaScript 也许功能没啥问题，但是几个月后，一旦你开始想调试或是改点东西，你可能特么找不到某个函数在哪了。\n \n-So if simply moving a bunch of code off HTML into another file isn’t enough, what’s the next solution?\n+若仅仅从HTML 中剥离出来是不够的，那么下一个解决方案是什么呢？","path":"TODO/leveling-up-your-javascript.md","position":35,"original_position":35,"commit_id":"22151d3502c54dc2ea6b143d3e6dbb21d9116500","original_commit_id":"22151d3502c54dc2ea6b143d3e6dbb21d9116500","user":{"login":"narcotics726","id":3340546,"avatar_url":"https://avatars.githubusercontent.com/u/3340546?v=3","gravatar_id":"","url":"https://api.github.com/users/narcotics726","html_url":"https://github.com/narcotics726","followers_url":"https://api.github.com/users/narcotics726/followers","following_url":"https://api.github.com/users/narcotics726/following{/other_user}","gists_url":"https://api.github.com/users/narcotics726/gists{/gist_id}","starred_url":"https://api.github.com/users/narcotics726/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narcotics726/subscriptions","organizations_url":"https://api.github.com/users/narcotics726/orgs","repos_url":"https://api.github.com/users/narcotics726/repos","events_url":"https://api.github.com/users/narcotics726/events{/privacy}","received_events_url":"https://api.github.com/users/narcotics726/received_events","type":"User","site_admin":false},"body":"所以，若仅仅把代码从 HTML 从抽取到一个单独文件中是不够的，那么还能怎么办呢？","created_at":"2016-04-19T03:25:01Z","updated_at":"2016-04-19T03:25:01Z","html_url":"https://github.com/xitu/gold-miner/pull/277#discussion_r60168873","pull_request_url":"https://api.github.com/repos/xitu/gold-miner/pulls/277","_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/60168873"},"html":{"href":"https://github.com/xitu/gold-miner/pull/277#discussion_r60168873"},"pull_request":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/277"}}},"pull_request":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/277","id":66843121,"html_url":"https://github.com/xitu/gold-miner/pull/277","diff_url":"https://github.com/xitu/gold-miner/pull/277.diff","patch_url":"https://github.com/xitu/gold-miner/pull/277.patch","issue_url":"https://api.github.com/repos/xitu/gold-miner/issues/277","number":277,"state":"open","locked":false,"title":"Leveling Up Your JavaScript 翻译完成 #162","user":{"login":"hikerpig","id":2259688,"avatar_url":"https://avatars.githubusercontent.com/u/2259688?v=3","gravatar_id":"","url":"https://api.github.com/users/hikerpig","html_url":"https://github.com/hikerpig","followers_url":"https://api.github.com/users/hikerpig/followers","following_url":"https://api.github.com/users/hikerpig/following{/other_user}","gists_url":"https://api.github.com/users/hikerpig/gists{/gist_id}","starred_url":"https://api.github.com/users/hikerpig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikerpig/subscriptions","organizations_url":"https://api.github.com/users/hikerpig/orgs","repos_url":"https://api.github.com/users/hikerpig/repos","events_url":"https://api.github.com/users/hikerpig/events{/privacy}","received_events_url":"https://api.github.com/users/hikerpig/received_events","type":"User","site_admin":false},"body":"偷懒了多处采用意译，请校对不要手软。\r\n\r\n哦还有，这篇抓取的原文有些地方不太对，像是 jQuery 的 `$` 符号没识别出来，我都在译文中修正了。还有原文的一些在原网站里应该属于figcaption之类的文字没有体现出来，我就没管，之后如果要发到掘金上，劳烦编辑费点力气。","created_at":"2016-04-18T12:15:08Z","updated_at":"2016-04-19T03:25:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34a36111d84ddb7c2f61d34e1a4cdf896e335c3b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xitu/gold-miner/pulls/277/commits","review_comments_url":"https://api.github.com/repos/xitu/gold-miner/pulls/277/comments","review_comment_url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xitu/gold-miner/issues/277/comments","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/22151d3502c54dc2ea6b143d3e6dbb21d9116500","head":{"label":"hikerpig:translate","ref":"translate","sha":"22151d3502c54dc2ea6b143d3e6dbb21d9116500","user":{"login":"hikerpig","id":2259688,"avatar_url":"https://avatars.githubusercontent.com/u/2259688?v=3","gravatar_id":"","url":"https://api.github.com/users/hikerpig","html_url":"https://github.com/hikerpig","followers_url":"https://api.github.com/users/hikerpig/followers","following_url":"https://api.github.com/users/hikerpig/following{/other_user}","gists_url":"https://api.github.com/users/hikerpig/gists{/gist_id}","starred_url":"https://api.github.com/users/hikerpig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikerpig/subscriptions","organizations_url":"https://api.github.com/users/hikerpig/orgs","repos_url":"https://api.github.com/users/hikerpig/repos","events_url":"https://api.github.com/users/hikerpig/events{/privacy}","received_events_url":"https://api.github.com/users/hikerpig/received_events","type":"User","site_admin":false},"repo":{"id":53376495,"name":"gold-miner","full_name":"hikerpig/gold-miner","owner":{"login":"hikerpig","id":2259688,"avatar_url":"https://avatars.githubusercontent.com/u/2259688?v=3","gravatar_id":"","url":"https://api.github.com/users/hikerpig","html_url":"https://github.com/hikerpig","followers_url":"https://api.github.com/users/hikerpig/followers","following_url":"https://api.github.com/users/hikerpig/following{/other_user}","gists_url":"https://api.github.com/users/hikerpig/gists{/gist_id}","starred_url":"https://api.github.com/users/hikerpig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikerpig/subscriptions","organizations_url":"https://api.github.com/users/hikerpig/orgs","repos_url":"https://api.github.com/users/hikerpig/repos","events_url":"https://api.github.com/users/hikerpig/events{/privacy}","received_events_url":"https://api.github.com/users/hikerpig/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hikerpig/gold-miner","description":"掘金翻译计划，翻译掘金上优质的英文文章","fork":true,"url":"https://api.github.com/repos/hikerpig/gold-miner","forks_url":"https://api.github.com/repos/hikerpig/gold-miner/forks","keys_url":"https://api.github.com/repos/hikerpig/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hikerpig/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hikerpig/gold-miner/teams","hooks_url":"https://api.github.com/repos/hikerpig/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/hikerpig/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/hikerpig/gold-miner/events","assignees_url":"https://api.github.com/repos/hikerpig/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/hikerpig/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/hikerpig/gold-miner/tags","blobs_url":"https://api.github.com/repos/hikerpig/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hikerpig/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hikerpig/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/hikerpig/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hikerpig/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/hikerpig/gold-miner/languages","stargazers_url":"https://api.github.com/repos/hikerpig/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/hikerpig/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/hikerpig/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/hikerpig/gold-miner/subscription","commits_url":"https://api.github.com/repos/hikerpig/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/hikerpig/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/hikerpig/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/hikerpig/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/hikerpig/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/hikerpig/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hikerpig/gold-miner/merges","archive_url":"https://api.github.com/repos/hikerpig/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hikerpig/gold-miner/downloads","issues_url":"https://api.github.com/repos/hikerpig/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/hikerpig/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/hikerpig/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/hikerpig/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hikerpig/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/hikerpig/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/hikerpig/gold-miner/deployments","created_at":"2016-03-08T02:41:00Z","updated_at":"2016-03-08T02:40:51Z","pushed_at":"2016-04-18T12:08:28Z","git_url":"git://github.com/hikerpig/gold-miner.git","ssh_url":"git@github.com:hikerpig/gold-miner.git","clone_url":"https://github.com/hikerpig/gold-miner.git","svn_url":"https://github.com/hikerpig/gold-miner","homepage":"http://gold.xitu.io","size":9118,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xitu:master","ref":"master","sha":"090bac59c5d6212dfde0409be8498004bdbc1dd0","user":{"login":"xitu","id":10482599,"avatar_url":"https://avatars.githubusercontent.com/u/10482599?v=3","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"repo":{"id":45512989,"name":"gold-miner","full_name":"xitu/gold-miner","owner":{"login":"xitu","id":10482599,"avatar_url":"https://avatars.githubusercontent.com/u/10482599?v=3","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xitu/gold-miner","description":"掘金翻译计划，翻译掘金上优质的英文文章","fork":false,"url":"https://api.github.com/repos/xitu/gold-miner","forks_url":"https://api.github.com/repos/xitu/gold-miner/forks","keys_url":"https://api.github.com/repos/xitu/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xitu/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xitu/gold-miner/teams","hooks_url":"https://api.github.com/repos/xitu/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/xitu/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/xitu/gold-miner/events","assignees_url":"https://api.github.com/repos/xitu/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/xitu/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/xitu/gold-miner/tags","blobs_url":"https://api.github.com/repos/xitu/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xitu/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xitu/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/xitu/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/xitu/gold-miner/languages","stargazers_url":"https://api.github.com/repos/xitu/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/xitu/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/xitu/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/xitu/gold-miner/subscription","commits_url":"https://api.github.com/repos/xitu/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/xitu/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/xitu/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/xitu/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/xitu/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/xitu/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xitu/gold-miner/merges","archive_url":"https://api.github.com/repos/xitu/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xitu/gold-miner/downloads","issues_url":"https://api.github.com/repos/xitu/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/xitu/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/xitu/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/xitu/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xitu/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/xitu/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/xitu/gold-miner/deployments","created_at":"2015-11-04T03:29:13Z","updated_at":"2016-04-19T03:21:29Z","pushed_at":"2016-04-19T01:54:43Z","git_url":"git://github.com/xitu/gold-miner.git","ssh_url":"git@github.com:xitu/gold-miner.git","clone_url":"https://github.com/xitu/gold-miner.git","svn_url":"https://github.com/xitu/gold-miner","homepage":"http://gold.xitu.io","size":9392,"stargazers_count":1166,"watchers_count":1166,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":234,"mirror_url":null,"open_issues_count":46,"forks":234,"open_issues":46,"watchers":1166,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/277"},"html":{"href":"https://github.com/xitu/gold-miner/pull/277"},"issue":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/277"},"comments":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/277/comments"},"review_comments":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/277/comments"},"review_comment":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/277/commits"},"statuses":{"href":"https://api.github.com/repos/xitu/gold-miner/statuses/22151d3502c54dc2ea6b143d3e6dbb21d9116500"}}}}