Solved! Go to Solution.
featureLayer = new esri.layers.FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServer/0",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
infoTemplate: infoTemplate,
outFields: ["*"]
});
featureLayer.hide(); // This will hide the layer
featureLayer.show(); // This will show the layervar myMap = new esri.Map("mapDiv"); // Say you have your map declared and assigned to myMap variable
var layerIdsArr = myMap.layerIds; // This gives ids of all layers added to map.
var layer = myMap.getLayer(layerIdsArr[0]);// Say you want layer with an id at first index of layerIdsArr
layer.hide();// Will hide layer
layer.show(); Will show layervar allLayersArr = esri.arcgisonline.map.main.mapLayers; //This gives you array of all layers object, log this to get the details of layers esri.arcgisonline.map.main.mapLayers[0].layer.hide(); // Will hide base layer esri.arcgisonline.map.main.mapLayers[1].layer.hide(); // Will hide layer at index 1, highlighted in light blue in your example esri.arcgisonline.map.main.mapLayers[2].layer.hide(); // Will hide layer at index 2, the symbols that identify different types of power outages