Understand Dot (.) vs Pipe (|) Separators
masterWhile . and | are often interchangeable, they behave differently when used after array/query operators (# or #( )):
- Dot (
.): Processes the path on each element of the preceding array before returning the results (mapping). - Pipe (
|): Processes the path on the result of the previous operation as a single entity (chaining).
If the previous result is an array, | treats that array as the new target, whereas . treats the elements inside the array as the targets.
// If friends.#(last="Murphy")# returns an array of objects:
friends.#(last="Murphy")#.first // Returns an array of 'first' names: ["Dale", "Jane"]
friends.#(last="Murphy")#|first // Returns <non-existent> because it looks for 'first' on the array itself
friends.#(last="Murphy")#|0 // Returns the first object in that array