#1696·terser

Moving variable declaration to parameter list

Author: GulgDevCreated Jun 20, 2026Updated Jun 20, 2026

In some cases it is possible to shorten the code by moving variable declarations to the parameter list of the containing function:

javascript
function f() {
    let value = 123;
    return {
        get: () => value,
        set(newValue) { value = newValue }
    };
}
// this can be shortened to:
export function f(t=123){return{get:()=>v,set(e){t=e}}}

Note that while this feature can heavily impact the bundle size, this relies on the fact that the function is not expected to take more arguments than its signature declares and sometimes can introduce unexpected bugs, so it would make sense to disable this optimization by default.