Object.freeze

Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

Syntax

freeze(object)

Parameters

Return value

The object that was passed to the function.

Examples

let obj = {cheese: "like", milk: "dislike"}
Object.freeze(obj)
obj.cheese = "dislike" // will have no effect
obj.cheese
"like"