You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`freeze` freezes an object. Freezing an object makes existing properties non-writable and prevents extensions. Once an object is frozen, new properties cannot be be added, existing properties cannot be removed, and their values cannot be changed.
56
+
57
+
**Note:** `freeze` returns the same object that was passed in; it does not create a frozen copy. Any attempt to change a frozen object will fail, either silently or by throwing an exception.
58
+
59
+
See [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.isfrozen) and [Object.isFrozen on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen).
60
+
61
+
## Examples
62
+
63
+
```rescript
64
+
let obj = {"a": 1}
65
+
obj->Object.set("a", 2) // succeeds
66
+
obj->Object.freeze->ignore
67
+
obj->Object.set("a", 3) // fails
68
+
```
69
+
*/
70
+
@val
71
+
externalfreeze: 'a=>'a="Object.freeze"
55
72
56
73
@valexternalisSealed: 'a=>bool="Object.isSealed"
57
-
@valexternalisFrozen: 'a=>bool="Object.isFrozen"
74
+
/**
75
+
`isFrozen` determines if an object is frozen. An object is frozen if an only if it is not extensible, all its properties are non-configurable, and all its data properties are non-writable.
76
+
77
+
See [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.isfrozen) and [Object.isFrozen on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen).
78
+
79
+
## Examples
80
+
81
+
```rescript
82
+
let point = {"x": 1, "y": 3}->Object.freeze
83
+
let pointIsFrozen = point->Object.isFrozen // true
84
+
let fruit = {"name": "Apple" }
85
+
let fruitIsFrozen = fruit->Object.isFrozen // false
0 commit comments