How to make function parameter constant in JavaScript?

后端 未结 8 1024
野的像风
野的像风 2020-12-13 12:43

What I want to do is to use as many immutable variables as possible, thus reducing the number of moving parts in my code. I want to use \"var\" and \"let\" only when it\'s n

8条回答
  •  时光说笑
    2020-12-13 13:27

    This is what I do:

    Instead of:

    function F(const a, const b, const c, const d, const e, const f, const g){ // Invalid Code
        // lorem
        // ipsum
    }
    

    ..Use:

    function F(){const[a, b, c, d, e, f, g] = arguments;
        // lorem
        // ipsum
    }
    

提交回复
热议问题