Object.freeze() and difference between const and Object.freeze()
In world of object oriented programming classes and objects are of utmost importance. Javascript doesn’t follow traditional class style of other languages. But JS does support objects like the way other languages do.

So if we can create object in JS in way the we do in other languages, we can edit that object as well.

But what if that created object is important enough that should not be changed like routes in applications? In that case this edit property is not a feature but a bug. But JS is created by coders. So they provide us a solution for this bug as well. And that solution is Object.freeze().
Object.freeze() comes in to picture when we don’t want to change the object. This method freezes the object which was passed to it. New property/ properties can not be added to that object and existing property/properties can not be removed . Object.freeze() takes an object as it’s parameter and returns that same object.

Diff between const and Object.freeze() :-
Const and Object.freeze() are totally different things.
Const is type of variable. Variable declared with const can not be reassigned.

This line will through a type error “Assignment to constant variable”. But we still can edit it’s property like firstName and lastName.

But if we use Object.freeze(), we can’t change that object, in any way, which was passed as argument to Object.freeze().

Object declared with const can not be reassigned but we can edit it’s property. If we use Object.freeze() then we can not edit the property of that object.