Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeConfluence
languagejavascript
a = { "colors" : "many",
      "pi" : [3,1,4,1,5,6,9],
      "foo" : {"bar" : {10: "I like cheese", "a" : 12}}
    };
b = a.keys();               // b = ["colors", "pi", "foo"]
c = a.keys(["foo", "bar"]); // c = [10, "a"]

values()

The values()operator returns the values of the map to which it is applied. Without an argument, the values at the top level of the map are returned. The operator also accepts a hash path argument. For example:

Code Block
themeConfluence
languagejavascript
a = { "colors" : "many",
      "pi" : [3,1,4,1,5,6,9],
      "foo" : {"bar" : {10: "I like cheese", "a" : 12}}
    };
b = a.values();               // b = ["many", [3,1,4,1,5,6,9], {"bar" : {10: "I like cheese", "a" : 12}}]
c = a.values(["foo", "bar"]); // c = ["I like cheese", 12]

put()

The put() operator takes two arguments: a hash path and a new element to be inserted. The result is a new data a structure with the element inserted at the location specified by the hash path. If the path specifies a location that does not exist, it will be created. For example:

...

Code Block
themeConfluence
languagejavascript
e = a.put(b);
// a = {"colors" : "many",
//      "pi" : [3,1,4,1,5,6,9]
//      "flop" : 12
//     };

values()

TheĀ values()operator returns the values of the map to which it is applied. Without an argument, the values at the top level of the map are returned. The operator also accepts a hash path argument. For example:

Code Block
themeConfluence
languagejavascript
a = { "colors" : "many",
      "pi" : [3,1,4,1,5,6,9],
      "foo" : {"bar" : {10: "I like cheese", "a" : 12}}
    };
b = a.values();               // b = ["many", [3,1,4,1,5,6,9], {"bar" : {10: "I like cheese", "a" : 12}}]
c = a.values(["foo", "bar"]); // c = ["I like cheese", 12]