3

If it was an immutable object, then I would have no doubt in declaring it as a const. But in this case it's just a const reference to an object while the object is modified later in the code.

const styles = {};
...
styles.width = rect.width + 'px';

I'm afraid it will be confusing for developers reading this code. It feels like let is more appropriate for objects that get mutated.

0 Answers0