Object, Bracket & Array Syntax
Each note of a notation is validated against ECMAScript variable syntax,
array-index notation, and object-bracket notation. Invalid notes never match —
and most methods throw a NotationError rather
than fail silently.
Property Keys
Section titled “Property Keys”Standard identifiers use dot notation. Non-standard keys (digits, dashes, symbols, reserved characters) must use bracket notation with quotes:
| Incorrect | Correct |
|---|---|
x[y] | x["y"] |
x.1 | x['1'] |
x.y-z | x["y-z"] |
x.@ | x['@'] |
Notation.isValid('x.y-z'); // » falseNotation.isValid('x["y-z"]'); // » trueArray Indices
Section titled “Array Indices”Brackets with a number address array items:
[0].x— thexproperty of the first item of a root array.x[1]— the second item of thexproperty of a root object.
const data = { tags: ['a', 'b', 'c'] };Notation.create(data).get('tags[1]'); // » "b"Wildcards
Section titled “Wildcards”Wildcards are glob-only — valid in filter()
and the NotationGlob class, but not in regular
notation.
| Pattern | Meaning |
|---|---|
* | all properties of an object |
[*] | all items of an array |
x[*] | all items of x (an array) |
x.* | all properties of x (an object) |
x['*'] | a literal * key — not a wildcard (valid regular notation) |
Notation.isValid('x.*'); // » false (glob only)NotationGlob.isValid('x.*'); // » trueWildcard Equivalence
Section titled “Wildcard Equivalence”For non-negated globs, trailing wildcards are redundant — they all normalize to the bare notation:
x = x.* = x.*.*[0] = [0][*]Negated versions are not equivalent — the trailing wildcard changes what’s removed:
!x— removexentirely.!x.*— emptyx’s first-level properties, but keepx(as{}).!x.*.*— empty only the second-level properties ofx.
!x ≠ !x[*]![*] ≠ ![*].*This distinction drives filtering and data integrity — worth internalizing before you write negated globs.