Files
freeCodeCamp/guide/chinese/javascript/standard-objects/object/object-isfrozen/index.md
2018-10-16 21:32:40 +05:30

39 lines
949 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Object isFrozen
localeTitle: 对象是冷冻
---
## 对象是冷冻
您可以使用**`Object.isFrozen()`**来确定对象是否已冻结。它返回**`true`**或**`false`**布尔值。
#### **句法**
```javascript
Object.isFrozen(obj)
```
**例如:**
```javascript
var foods = {
grain : "wheat",
dairy : "milk",
vegetable : "carrot",
fruit : "grape"
};
var frozenFoods = Object.freeze(foods);
var areMyFoodsFrozen = Object.isFrozen(frozenFoods);
\\ returns true
```
请记住,冻结的对象**不能**更改其属性。
如果您尝试在非对象参数上使用**`Object.isFrozen()`** ,它将返回`true`
#### 更多信息:
[MDN Object.isFrozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
[MDN Object.freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)