To delete items with script you can use deleteItem method with item ID passed into it. You also can pass array of IDs to delete more than one item at once. You can use the following set of commands to delete selected item(s):
myFolders.deleteItem(myFolders.getSelectedId();