IDBKeyRange: includes() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{ APIRef("IndexedDB") }} {{AvailableInWorkers}}
The includes() method of the {{domxref("IDBKeyRange")}} interface returns a boolean indicating whether a specified key is inside the key range.
Syntax
js-nolint
includes(key)Parameters
key- : The key you want to check for in your key range. This can be any type.
Return value
A boolean value.
Exceptions
DataError{{domxref("DOMException")}}- : Thrown if the supplied key was not a valid key.
Examples
js
const keyRangeValue = IDBKeyRange.bound("A", "K", false, false);
keyRangeValue.includes("F");
// Returns true
keyRangeValue.includes("W");
// Returns falseSpecifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- Using IndexedDB
- Starting transactions: {{domxref("IDBDatabase")}}
- Using transactions: {{domxref("IDBTransaction")}}
- Setting a range of keys: {{domxref("IDBKeyRange")}}
- Retrieving and making changes to your data: {{domxref("IDBObjectStore")}}
- Using cursors: {{domxref("IDBCursor")}}
- Reference example: To-do Notifications (View the example live).