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"]

map()

The map() operator returns a map that contains the results of applying the function given as the operator's argument to each key-value pair from the original map. The function given as an argument must take two arguments: the first will be the key and the second the value. The result will be a map with the same keys, each key mapped to the result of the function. The length of the resulting map will be equal to the length of the target map. For example:

Code Block
themeConfluence
languagejavascript
a = {"a": 3, "b": 4, "c": 5};
c = a.map(function(k,v) {v+2}) // c = {"a": 5, "b": 6, "c": 7}

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:

...