Few common scenarios when you are working with the graphics layer (@ version 1.3) in the ArcGIS Server JS API
1. map.graphics returns the graphics layer
2. map.graphics.graphics returns the array of graphic elements (geometry, symbol, attribute, infotemplate) added to the graphics layer
To remove all graphic elements in the graphic layer
map.graphics.clear();
To show/hide specific graphic element
map.graphics.graphics[index].show();
map.graphics.graphics[index].hide();
To check if any specific graphic element is being shown or not:
// 'none' is hidden and 'block' is visible
map.graphics.graphics[index].getDojoShape().rawNode.style.display
Loop through all the graphic elements
var graphics = map.graphics.graphics;
for (var i=0; i< graphics.length; i++)
{
// do something with graphics[i]
}
even better
dojo.forEach(map.graphics.graphics, "console.log(item.getDojoShape().rawNode.style.display)");
//or
dojo.forEach(map.graphics.graphics, "console.log(item,index,array)");
//or
dojo.forEach(map.graphics.graphics, function(item){//item is a graphic element });
Note: @version 1.4 you will have ability to add multiple graphics layers (in addition to the default graphics layer) and can control the stack order (z-index).