clone( item )

Returns a copy of the supplied item.

:-) "hello".clone;
There is 1 result
"hello"
      

The returned object is a shallow copy of the original item. This means that cloning a list would produce a new list, but the underlying list items are not cloned, e.g.

:-) var item1 = newList( 1, 2, 3 );
:-) var item2 = newList( "a", "b", "c" );
:-) var list = newList( item1, item2 );
:-) list;
There is 1 result
[[1, 2, 3], [a, b, c]]
:-) item1[2] := 4
There are 0 results
:-) item2[1] := "oops";
There are 0 results
:-) list;
There is 1 result
[[1, 4, 3], [oops, b, c]]
      

There is one possible issue with the code: it relies on the Java Cloneable iterface and the clone method. If the specified item doesn't support both the clone function will return it's argument, e.g.

:-) var test = "hello";
There are 0 results
:-) test.clone == test;
There is 1 result
<true>