Giter Club home page Giter Club logo

campus-recruitment's People

Contributors

monkindey avatar timtsang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

campus-recruitment's Issues

关于实现函数range([start,]stop[,step])

range([start,]stop[,step])

1.个人认为题目规定了stop是一定要传的, 所以参数为0的时候, 应该抛出错误

function range() {
    var argLength = arguments.length,
    array = [],
    i = 0,
    start = arguments[0],
    stop = arguments[1],
    step = arguments[2];
    switch(argLength) {

        case 0: 
            throw Error('至少输入一个参数,限止数组在哪里结束');

        case 1: 
            stop = arguments[0];
            for(i = 0; i < stop; i++) {
                array.push(i);
            }
            return array;
        case 2:
            for(i = start; i < stop; i++) {
                array.push(i);
            }
            return array;
        case 3:
            if(step < 1) {
                throw Error('step > 1');
            }
            for(i = start; i < stop; i+=step) {
                array.push(i);
            }
            return array;
        default : 
            throw Error('最多传入三个参数');
    }
}

2. 在throw Error 和 return 之后加break JSLint 报错 Unreachable 'break' after 'return'

3. for 循环里的多次的声明变量 i

4. for循环的性能优化 js会在每次循环的时候重新去获取 arguments 和 HTMLCollecttion 所以要缓存起来 更新了地址

5. 没有考虑start > stop 的情况

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.