Skip to content

void 0 can be optimized to an unassigned variable #2585

Open
@LunaBorowska

Description

@LunaBorowska

Bug report or feature request?

Feature request

ES5 or ES6+ input?

ES5

Uglify version (uglifyjs -V)

uglify-js 3.2.2

JavaScript input

function f(){var h=prompt();return[void 0,h/h]}

The uglifyjs CLI command executed or minify() options used.

Default

JavaScript output or error produced.

function f(){var h=prompt();return[void 0,h/h]}

This can be further optimized as this:

function f(){var h=prompt(),u;return[u,h/h]}

This saves 5 bytes per each undefined usage as long at least one variable was declared in a function scope, at cost of having to use 2 extra bytes for var declaration. var declaration can be inserted in a scope above in event there is a function within a function for extra savings.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions