Skip to content

Minor Cleanup: Use Cached slice Reference in app.listen Implementation #6896

@Tacit1

Description

@Tacit1

Description

While reviewing the application.js file, I noticed that Express defines:

var slice = Array.prototype.slice

but later in app.listen, it still uses the full property access:

var args = Array.prototype.slice.call(arguments)

This can be simplified to use the cached reference:

var args = slice.call(arguments)`

Expected Behavior

Use the already-defined slice reference for consistency and to avoid repeating

Array.prototype.slice 

The behavior remains identical.

Actual Behavior

The code currently uses the direct prototype access instead of the cached reference.

Rationale

  • Improves consistency within the file

  • Avoids repeated long-form prototype access

  • Slight micro-optimization (cached function reference)

  • No behavioral changes

  • All tests continue to pass

Proposed Change

Replace:

var args = Array.prototype.slice.call(arguments)

with:

var args = slice.call(arguments)

I am happy to submit a pull request if maintainers consider this cleanup acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions