I'm not asking what's technically possible; I know you can do
const a = [];
const b = {};
a.push['sup'];
b.test = 'earth';
What I'm wondering is whether there's any convention for preferring let
over const
when it comes to arrays and objects that will have their internals modified. If you see an object declared with const
, do you assume the intention was for the object to be immutable, and would you have preferred to see let
instead, or, since some linters (like tslint) have a problem with that, is it better just to declare it with const
and trust that anyone else reading the code knows that that doesn't mean it's immutable?