typecode queries

The typecode identifies the kind of value stored in a StoreObject.

To find the kind of value, use O.typecode() to determine the typecode, and compare against the value or text types.

Using O.typecode() repeatedly is slow, so try to avoid using it in loops. Faster alternatives for the most common queries are provided. To test if something is a Ref or Text, use O.isRef() or O.isText() respectively.

function O.typecode(value)

Returns the typecode of the value.

Returns null if the value cannot be stored in a StoreObject.

It will return O.T_TEXT if a String object is tested. This is a convenience as String objects are automatically converted to Text objects when added to a StoreObject.

Because JavaScript represents all numbers as floating point, the difference between integers and floating point numbers is a little hard to determine. O.typecode() returns O.T_INTEGER when the number is an integer, and O.T_NUMBER if it has a fractional part. Be careful of this distinction. typeof(value)==="number" may be a more useful test in some circumstances.

O.T_DATETIME will be returned for JavaScript Date objects in addition to proper DateTime objects, since both can be used with the append() functions on a StoreObject.

The values that can be returned are listed for text and other values types.

function O.isRef(value)

Returns true if value is a Ref object.

function O.isText(value)

Returns true if value is a Text object.

Note it will not return true if a String is tested.