This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

cmp

Summary

This method compares two specified keys. Returns 1 if the first key is greater than the second, -1 if the first is less than the second, and 0 if the first is equal to the second.

Method of apis/indexeddb/IDBFactoryapis/indexeddb/IDBFactory

Syntax

var result = window.indexeddb.cmp(first, second);

Parameters

first

Data-type
DOM Node

The first key to compare

second

Data-type
String

The second key to compare

Return Value

Returns an object of type NumberNumber

The method returns 1 if the first key is greater than the second, -1 if the first is less than the second, and 0 if the first is equal to the second. Throws a DOMException (Data Error) is one of the supplied keys was not a valid key.

Examples

var value1 = "Alpha";
var value2 = "Beta";
var result = window.indexedDB.cmp( value1, value2 );
console.log( "Comparison results: " + result );

Related specifications

W3C IndexedDB Specification
W3C Proposed Recommendation

Attributions