{"action":"created","issue":{"url":"https://api.github.com/repos/topview-frontend/campus-recruitment/issues/1","labels_url":"https://api.github.com/repos/topview-frontend/campus-recruitment/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/topview-frontend/campus-recruitment/issues/1/comments","events_url":"https://api.github.com/repos/topview-frontend/campus-recruitment/issues/1/events","html_url":"https://github.com/topview-frontend/campus-recruitment/issues/1","id":66327201,"number":1,"title":"关于实现函数range([start,]stop[,step])","user":{"login":"L-movingon","id":9621533,"avatar_url":"https://avatars.githubusercontent.com/u/9621533?v=3","gravatar_id":"","url":"https://api.github.com/users/L-movingon","html_url":"https://github.com/L-movingon","followers_url":"https://api.github.com/users/L-movingon/followers","following_url":"https://api.github.com/users/L-movingon/following{/other_user}","gists_url":"https://api.github.com/users/L-movingon/gists{/gist_id}","starred_url":"https://api.github.com/users/L-movingon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/L-movingon/subscriptions","organizations_url":"https://api.github.com/users/L-movingon/orgs","repos_url":"https://api.github.com/users/L-movingon/repos","events_url":"https://api.github.com/users/L-movingon/events{/privacy}","received_events_url":"https://api.github.com/users/L-movingon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-04T14:36:41Z","updated_at":"2015-04-04T16:44:41Z","closed_at":null,"body":"# range([start,]stop[,step])\r\n\r\n#### 1.个人认为题目规定了stop是一定要传的, 所以参数为0的时候, 应该抛出错误\r\n\r\n    function range() {\r\n        var argLength = arguments.length,\r\n        array = [],\r\n        i = 0,\r\n        start = arguments[0],\r\n        stop = arguments[1],\r\n        step = arguments[2];\r\n        switch(argLength) {\r\n\r\n            case 0: \r\n                throw Error('至少输入一个参数,限止数组在哪里结束');\r\n\r\n            case 1: \r\n                stop = arguments[0];\r\n                for(i = 0; i < stop; i++) {\r\n                    array.push(i);\r\n                }\r\n                return array;\r\n            case 2:\r\n                for(i = start; i < stop; i++) {\r\n                    array.push(i);\r\n                }\r\n                return array;\r\n            case 3:\r\n                if(step < 1) {\r\n                    throw Error('step > 1');\r\n                }\r\n                for(i = start; i < stop; i+=step) {\r\n                    array.push(i);\r\n                }\r\n                return array;\r\n            default : \r\n                throw Error('最多传入三个参数');\r\n        }\r\n\t}\r\n    \r\n\r\n\r\n#### 2. 在throw Error 和 return 之后加break JSLint 报错 Unreachable 'break' after 'return'\r\n\r\n#### 3. for 循环里的多次的声明变量 i\r\n\r\n#### 4. for循环的性能优化 js会在每次循环的时候重新去获取 arguments 和 HTMLCollecttion  所以要缓存起来 [更新了地址](http://www.css119.com/archives/1452)\r\n\r\n#### 5. 没有考虑start > stop 的情况"},"comment":{"url":"https://api.github.com/repos/topview-frontend/campus-recruitment/issues/comments/89612455","html_url":"https://github.com/topview-frontend/campus-recruitment/issues/1#issuecomment-89612455","issue_url":"https://api.github.com/repos/topview-frontend/campus-recruitment/issues/1","id":89612455,"user":{"login":"TimTsang","id":8758718,"avatar_url":"https://avatars.githubusercontent.com/u/8758718?v=3","gravatar_id":"","url":"https://api.github.com/users/TimTsang","html_url":"https://github.com/TimTsang","followers_url":"https://api.github.com/users/TimTsang/followers","following_url":"https://api.github.com/users/TimTsang/following{/other_user}","gists_url":"https://api.github.com/users/TimTsang/gists{/gist_id}","starred_url":"https://api.github.com/users/TimTsang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimTsang/subscriptions","organizations_url":"https://api.github.com/users/TimTsang/orgs","repos_url":"https://api.github.com/users/TimTsang/repos","events_url":"https://api.github.com/users/TimTsang/events{/privacy}","received_events_url":"https://api.github.com/users/TimTsang/received_events","type":"User","site_admin":false},"created_at":"2015-04-04T16:44:41Z","updated_at":"2015-04-04T16:44:41Z","body":">* 1、师弟看题目挺仔细的哈，`stop`是没有`[ ]`括起来的，`stop`是必须要传的。\r\n>* 2、关于`JSLint`，这个的确是挺严格的，为了规范点，等下我改过来哈。\r\n>* 3、关于`i`、`arguments`和`HTMLCollecttion`相关的性能问题,因为做的时候比较赶时间，所以没注意到，谢谢提醒哈！\r\n"}}