Class ScriptProperties
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Thuộc tính của tập lệnh
Không dùng nữa. Lớp này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Thuộc tính tập lệnh là các cặp khoá-giá trị do tập lệnh lưu trữ trong một bộ nhớ cố định. Thuộc tính tập lệnh được đặt trong phạm vi của mỗi tập lệnh, bất kể người dùng nào chạy tập lệnh đó.
Các phương thức ngừng hoạt động
Các phương thức ngừng hoạt động
deleteAllProperties()
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Xoá tất cả tài sản.
ScriptProperties.deleteAllProperties();
Cầu thủ trả bóng
ScriptProperties
– đối tượng này, để tạo chuỗi
Xem thêm
deleteProperty(key)
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Xoá thuộc tính bằng khoá đã cho.
ScriptProperties.deleteProperty('special');
Tham số
Tên | Loại | Mô tả |
key | String | khoá của tài sản cần xoá |
Cầu thủ trả bóng
ScriptProperties
– đối tượng này, để tạo chuỗi
Xem thêm
getKeys()
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Lấy tất cả các khoá có sẵn.
Cầu thủ trả bóng
String[]
getProperties()
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Lấy tất cả các thuộc tính có sẵn cùng một lúc.
Thao tác này sẽ tạo một bản sao, chứ không phải chế độ xem trực tiếp, vì vậy, việc thay đổi các thuộc tính trên đối tượng được trả về sẽ không cập nhật các thuộc tính đó trong bộ nhớ và ngược lại.
ScriptProperties.setProperties({
"cow" : "moo",
"sheep" : "baa",
"chicken" : "cluck"
});
// Logs "A cow goes: moo"
Logger.log("A cow goes: %s", ScriptProperties.getProperty("cow"));
// This makes a copy. Any changes that happen here will not
// be written back to properties.
var animalSounds = ScriptProperties.getProperties();
// Logs:
// A chicken goes cluck!
// A cow goes moo!
// A sheep goes baa!
for(var kind in animalSounds) {
Logger.log("A %s goes %s!", kind, animalSounds[kind]);
}
Cầu thủ trả bóng
Object
– bản sao của các thuộc tính chứa cặp khoá-giá trị
getProperty(key)
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Trả về giá trị được liên kết với khoá đã cung cấp hoặc giá trị rỗng nếu không có giá trị nào như vậy.
const specialValue = ScriptProperties.getProperty('special');
Tham số
Tên | Loại | Mô tả |
key | String | khoá cho giá trị cần truy xuất |
Cầu thủ trả bóng
String
– giá trị được liên kết với khoá
Xem thêm
setProperties(properties)
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Đặt hàng loạt tất cả các thuộc tính được lấy từ đối tượng đã cho.
ScriptProperties.setProperties({special: 'sauce', 'meaning': 42});
Tham số
Tên | Loại | Mô tả |
properties | Object | một đối tượng chứa các thuộc tính cần đặt. |
Cầu thủ trả bóng
ScriptProperties
– đối tượng này, để tạo chuỗi
Xem thêm
setProperties(properties, deleteAllOthers)
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Đặt hàng loạt tất cả các thuộc tính được lấy từ đối tượng đã cho.
// This deletes all other properties
ScriptProperties.setProperties({special: 'sauce', 'meaning': 42}, true);
Tham số
Tên | Loại | Mô tả |
properties | Object | một đối tượng chứa các thuộc tính cần đặt. |
deleteAllOthers | Boolean | liệu có xoá tất cả tài sản hiện có hay không. |
Cầu thủ trả bóng
ScriptProperties
– đối tượng này, để tạo chuỗi
Xem thêm
setProperty(key, value)
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Duy trì giá trị được chỉ định trong với khoá được cung cấp. Mọi giá trị hiện có liên kết với khoá này sẽ bị ghi đè.
ScriptProperties.setProperty('special', 'sauce');
Tham số
Tên | Loại | Mô tả |
key | String | khoá cho thuộc tính |
value | String | giá trị để liên kết với khoá |
Cầu thủ trả bóng
ScriptProperties
– đối tượng này, để tạo chuỗi
Xem thêm
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eScriptProperties is deprecated and should not be used in new scripts, serving as a persistent key-value store scoped per script.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for setting, getting, and deleting properties, but these are all deprecated.\u003c/p\u003e\n"],["\u003cp\u003eDespite offering functionalities like bulk operations and property retrieval, developers should refrain from using them in new projects.\u003c/p\u003e\n"],["\u003cp\u003eThe class is primarily for legacy scripts and should be replaced with more modern alternatives for data persistence.\u003c/p\u003e\n"]]],[],null,["# Class ScriptProperties\n\nScriptProperties\n\n\n**Deprecated.** This class is deprecated and should not be used in new scripts.\n\nScript Properties are key-value pairs stored by a script in a persistent store. Script Properties\nare scoped per script, regardless of which user runs the script. \n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------------------|-----------------------|----------------------------------------------------------------------------------------|\n| [deleteAllProperties()](#deleteAllProperties()) | [ScriptProperties](#) | Deletes all properties. |\n| [deleteProperty(key)](#deleteProperty(String)) | [ScriptProperties](#) | Deletes the property with the given key. |\n| [getKeys()](#getKeys()) | `String[]` | Get all of the available keys. |\n| [getProperties()](#getProperties()) | `Object` | Get all of the available properties at once. |\n| [getProperty(key)](#getProperty(String)) | `String` | Returns the value associated with the provided key, or null if there is no such value. |\n| [setProperties(properties)](#setProperties(Object)) | [ScriptProperties](#) | Bulk-sets all the properties drawn from the given object. |\n| [setProperties(properties, deleteAllOthers)](#setProperties(Object,Boolean)) | [ScriptProperties](#) | Bulk-sets all the properties drawn from the given object. |\n| [setProperty(key, value)](#setProperty(String,String)) | [ScriptProperties](#) | Persists the specified in value with the provided key. |\n\nDeprecated methods\n------------------\n\n### `delete``All``Properties()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDeletes all properties.\n\n```javascript\nScriptProperties.deleteAllProperties();\n```\n\n#### Return\n\n\n[ScriptProperties](#) --- this object, for chaining\n\n#### See also\n\n- [deleteProperty(key)](#deleteProperty(String))\n\n*** ** * ** ***\n\n### `delete``Property(key)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDeletes the property with the given key.\n\n```javascript\nScriptProperties.deleteProperty('special');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-------|----------|----------------------------|\n| `key` | `String` | key for property to delete |\n\n#### Return\n\n\n[ScriptProperties](#) --- this object, for chaining\n\n#### See also\n\n- [deleteAllProperties()](#deleteAllProperties())\n\n*** ** * ** ***\n\n### `get``Keys()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGet all of the available keys.\n\n#### Return\n\n\n`String[]`\n\n*** ** * ** ***\n\n### `get``Properties()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGet all of the available properties at once.\n\nThis gives a copy, not a live view, so changing the properties on the returned object won't\nupdate them in storage and vice versa.\n\n```javascript\nScriptProperties.setProperties({\n \"cow\" : \"moo\",\n \"sheep\" : \"baa\",\n \"chicken\" : \"cluck\"\n});\n\n// Logs \"A cow goes: moo\"\nLogger.log(\"A cow goes: %s\", ScriptProperties.getProperty(\"cow\"));\n\n// This makes a copy. Any changes that happen here will not\n// be written back to properties.\nvar animalSounds = ScriptProperties.getProperties();\n\n// Logs:\n// A chicken goes cluck!\n// A cow goes moo!\n// A sheep goes baa!\nfor(var kind in animalSounds) {\n Logger.log(\"A %s goes %s!\", kind, animalSounds[kind]);\n}\n```\n\n#### Return\n\n\n`Object` --- a copy of the properties containing key-value pairs\n\n*** ** * ** ***\n\n### `get``Property(key)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nReturns the value associated with the provided key, or null if there is no such value.\n\n```javascript\nconst specialValue = ScriptProperties.getProperty('special');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-------|----------|-------------------------------|\n| `key` | `String` | key for the value to retrieve |\n\n#### Return\n\n\n`String` --- the value associated with the key\n\n#### See also\n\n- [setProperty(key, value)](#setProperty(String,String))\n\n*** ** * ** ***\n\n### `set``Properties(properties)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nBulk-sets all the properties drawn from the given object.\n\n```javascript\nScriptProperties.setProperties({special: 'sauce', 'meaning': 42});\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------|----------|---------------------------------------------|\n| `properties` | `Object` | an object containing the properties to set. |\n\n#### Return\n\n\n[ScriptProperties](#) --- this object, for chaining\n\n#### See also\n\n- [setProperty(key, value)](#setProperty(String,String))\n\n*** ** * ** ***\n\n### `set``Properties(properties, deleteAllOthers)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nBulk-sets all the properties drawn from the given object.\n\n```javascript\n// This deletes all other properties\nScriptProperties.setProperties({special: 'sauce', 'meaning': 42}, true);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------------|-----------|---------------------------------------------|\n| `properties` | `Object` | an object containing the properties to set. |\n| `delete``All``Others` | `Boolean` | whether to delete all existing properties. |\n\n#### Return\n\n\n[ScriptProperties](#) --- this object, for chaining\n\n#### See also\n\n- [setProperty(key, value)](#setProperty(String,String))\n\n*** ** * ** ***\n\n### `set``Property(key, value)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nPersists the specified in value with the provided key. Any existing value associated with this\nkey will be overwritten.\n\n```javascript\nScriptProperties.setProperty('special', 'sauce');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|---------------------------------|\n| `key` | `String` | key for property |\n| `value` | `String` | value to associate with the key |\n\n#### Return\n\n\n[ScriptProperties](#) --- this object, for chaining\n\n#### See also\n\n- [getProperty(key)](#getProperty(String))"]]