Is array.push a form of reassignment?

Viewed 2840

I'm working in a project with several javascript files and part of what I'm doing right now is both migrating existing code to use newer ES6+ features as well as making sure we're abiding by the AirBnB Eslint Rules.

So, given that context, this is the specific situation:

let meta = [a.platform];

And right below that:

meta.push(a.browserName ? a.browserName : 'any');

So now the linter is giving me a warning: 'meta is never reassigned. Use const instead'.


I understand that meta = somethingNew would be reassigning the variable. But in this case, isn't this variable also something different than what it used to be when it was created?

or, to make it even more clear

Can I use a const to define an array that will receive new items? If not, why?

Also, if not: why is the linter throwing a warning?

2 Answers
Related