new Tags( [data])
Create a new Tags object. The Tags object is an instance of a Map, and so has all the standard Map methods and properties: `clear`, `delete`, `entries`, `forEach`, `get`, `has`, `keys`, `set`, `size`, and `values`.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
data |
Object | Iterable |
<optional> |
The raw data to use for this Tags object. May either be an object of tags and their values, or an iterable object where each item is an array containing a tag and its value (the standard method of instantiating a Map object; see MDN's Map documentation for more details.). |
Example
const tags = new Tags({ accented: true, phraseFinal: false, grammaticalRole: 'subject', }); tags.set('itemNum', 13); console.log(tags.get('grammaticalRole')); // 'subject' console.log(tags.has('phraseFinal')); // true console.log(tags.get('itemNum')); // 13 console.log(tags.keys()); // ['accented', 'phraseFinal', 'grammaticalRole']
Extends
- Map
Methods
-
toJSON()
-
Returns a pure JavaScript object (POJO) for serialization into JSON using JSON.stringify(). Note that if you call JSON.stringify on a Tags object, it will call the the Tag object's toJSON() method.
Returns:
The JSON representation of the Tags object, as a pure JavaScript object (POJO)- Type
- Object