Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

no-param-reassign: arguments object is mutated anyhow #686

Closed
@mrmowji

Description

@mrmowji

I was testing ESLint for the first time and I decided to use Airbnb style guide.

Let's use an example from the page:

function foo(bar) {
  var baz = bar;
}

It passes ESLint check.

But the main point for Disallowing Reassignment of Function Parameters is that we don't mutate arguments object unintentionally.

But I think that's only true if the bar is of primitive type. Because every time I pass a value of a complex type as the argument, arguments is mutated after var baz = bar;:

function foo(bar) {
  var baz = bar;
  baz.property1 = 5;
  return arguments[0];
}

foo({ property0: 2 }); // returns { property0: 2, property1: 5 }

I just got more curious when I read a comment with lots of points regarding the same issue, but for DOM. I tried the DOM objects too. The result is the same; arguments[0] is mutated.

Am I missing something?
If it's true only for primitive types, then that'd be great to mention something about it on the docs. If it's a general thing, what about the behavior I'm experiencing? What's the point?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionThis issue asks a question about ESLint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions