Function parameters will stay mutable bindings (like var
) in ES6, there's nothing you can do against that. Probably the best solution you get is to destructure the arguments
object in a const
initialisation:
function hasConstantParameters(const a, const b, const c, …) { // not possible
…
}
function hasConstantParameters() {
const [a, b, c, …] = arguments;
…
}
Notice that this function will have a different arity (.length
), if you need that you'll have to declare some placeholder parameters.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…