Versions Compared

Key

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

...

Code Block
themeConfluence
languagejavascript
{"bar" : {10:"I like cheese"}}

delete()

The delete() operator takes a hash path argument designating the member of the original data structure that should be deleted. The delete() operator returns a new data structure with the specified member deleted. If the path is invalid, nothing is deleted and the new data structure is identical to the original. 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.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:

...