IndexedDB - ECMAScript Binding



Firstly, what is ECMAScript?

ECMAScript (European Computer Manufacturers Association Script) is a scripting language based on JavaScript.

JavaScript ES6 adds new syntaxes and features so that the code is more easily readable and we can write less code for the same functionality. ES6 has many new features like arrow functions, template strings, class destruction, etc.

Binding - Bind an object to a function and reference it using the ‘this’ keyword.

ECMAScript deals with keys, values, and keypaths.

It defines how key values defined in this specification are converted to and from ECMAScript values.

Extract a key from a value

To extract a key from a value using a key path with value, keyPath, and an optional multi-entry flag we need to follow the following steps. The results can be a key, invalid, failure, or even an exception.

  • Where r is the result of evaluating a keypath on a value with value and keypath. Rethrow any exceptions. If r is a failure return failure.

  • key be the result of converting a value to a key with r if the multi-entry flag is false, and the result of converting a value to a multi-entry key with r otherwise. Rethrow any exceptions.

  • If the key is invalid, return invalid.

  • Return key.

Advertisements