确定浏览器支持的IndexedDB版本

问题描述:

有没有一种方法可以确定浏览器支持的IndexDB版本?我知道2.0版本可用,但并不能告诉我浏览器实际支持哪个版本。寻找一个JavaScript解决方案。确定浏览器支持的IndexedDB版本

使用特征检测,例如,

if ('getAll' in IDBObjectStore.prototype) { 
    // you can use getAll 
} else { 
    // nope 
} 

或:

try { 
    indexedDB.cmp(new UInt8Array([]), 0); 
    // you can use binary keys 
} catch (e) { 
    // nope 
} 

版本为规格;浏览器逐步推出功能。