identifyParams.layerIds = [0,2]; identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
Sounds like a bug/typo in the sample. The default value for layerOption is that only the top-most visible layer is identified. So the sample should probably specify the visible layers and set the layerOption to LAYER_OPTION_VISIBLE instead of all.
I'm still not clear as to whether both parameters should be included or not. The API says that by specifying layerids then only those layers will be identified. It doesn't say anything about whether the layers are visible or not. Whereas the layer_option parameter is about visibility.