rectangle.width *= 2

This way is totally not recommended in OOP design. Other than violates the encapsulation principle, it also has no “OOP” smell. The correct way is:

const doubleWidthRectangle = rectangle.doubleWidth();

People can chose to go with this way or others, it depends. But my point is the mindset is more important here. Even if people using JS can easily making this mistake:

rectangle.width *= 2
    Le Truong Quoc Thang

    Written by

    Software Engineer