Skip to content

[question] Why do many files in the lib directory use var sometimes and let other times? #28009

@MilesZew

Description

@MilesZew
  • Version: 12.3.1

While looking through the node.js source code, I have found quite a few var declarations. In the same files I have also found let declarations. let declarations are almost always considered better, and can always be used in place of var declarations. I was thinking about fixing this and creating a PR but wanted to know if there was a specific reason for using var sometimes and let other times. Scope could be a reason, but could be transformed like this:

if(/*...*/) {
    var foo = 'bar';
}

//is the same as
let foo;
if(/*...*/) {
    foo = 'bar';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions