If an object is a PageItem
and supports the contentPlace()
method, you can place another object inside of it (documentation). For example, if there are two rectangles on a page and you want to place one rectangle inside the other, you could use something like this:
var doc = app.activeDocument;
var page = doc.pages[0];
var rect = page.rectangles[0];
var rect2 = page.rectangles[1];
rect.contentPlace([rect2]); // Content place duplicates the item,
rect2.remove(); // so it needs to be removed after moving it.