I have an application that has 4 layers that I want to stay available in my map at all times. In my layer list, they appear as follows:

The code that creates the layers follows:
<SPAN class="keyword token">var</SPAN> featurelayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//adds a feature layer of 2018 Crime</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F172.20.25.165%3A6080%2Farcgis%2Frest%2Fservices%2FCrime2018_110218%2FFeatureServer" target="_blank">http://172.20.25.165:6080/arcgis/rest/services/Crime2018_110218/FeatureServer</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>
title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"2018 Crime"</SPAN><SPAN class="punctuation token">,</SPAN>
renderer<SPAN class="punctuation token">:</SPAN> crimeRenderer<SPAN class="punctuation token">,</SPAN>
visible<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN>
popupEnabled<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN>
popupTemplate<SPAN class="punctuation token">:</SPAN> crimePopupTemplate
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>featurelayer<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> apdbeatsLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//adds a feature layer of APD Beats</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F172.20.25.165%3A6080%2Farcgis%2Frest%2Fservices%2FAPD_Beats_Feature%2FFeatureServer" target="_blank">http://172.20.25.165:6080/arcgis/rest/services/APD_Beats_Feature/FeatureServer</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>
title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"APD Beats"</SPAN><SPAN class="punctuation token">,</SPAN>
renderer<SPAN class="punctuation token">:</SPAN> beatsRenderer<SPAN class="punctuation token">,</SPAN>
popupEnabled<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN>
popupTemplate<SPAN class="punctuation token">:</SPAN> beatsPopupTemplate<SPAN class="punctuation token">,</SPAN>
opacity<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">0.5</SPAN><SPAN class="punctuation token">,</SPAN>
visible<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>apdbeatsLayer<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> orthLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ImageryLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//adds an image layer of Orthos SCE</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F172.20.25.165%3A6080%2Farcgis%2Frest%2Fservices%2FOrtho_SCE%2FImageServer" target="_blank">http://172.20.25.165:6080/arcgis/rest/services/Ortho_SCE/ImageServer</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>
title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Ortho - East"</SPAN><SPAN class="punctuation token">,</SPAN>
visible<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>orthLayer<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> orthLayer2 <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ImageryLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//adds an image layer of Orthos SCW</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F172.20.25.165%3A6080%2Farcgis%2Frest%2Fservices%2FOrtho_SCW%2FImageServer" target="_blank">http://172.20.25.165:6080/arcgis/rest/services/Ortho_SCW/ImageServer</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>
title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Ortho - West"</SPAN><SPAN class="punctuation token">,</SPAN>
visible<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>orthLayer2<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>At any time, the user may choose a month from a menu, and a query runs against the 'featurelayer' and then displays only the crimes for that month in a new featurelayer :

Here you can see that I have added 4 months of crime data to the map, each layer a different color, and you can also see the layers show up in the layer list :

I have a radial menu, which has an icon to click to remove any added layers from the layer list, as it can get crowded quick:

The icon code for removing the added layers, and leaving the 4 default layers is as follows:
<SPAN class="token function">$</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"#ichyPic"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">click</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> layLength <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">.</SPAN>length<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">/*alert(layLength);
map.layers.removeAll();*/</SPAN>
<SPAN class="keyword token">while</SPAN> <SPAN class="punctuation token">(</SPAN>layLength <SPAN class="operator token">></SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
map<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">removeAt</SPAN><SPAN class="punctuation token">(</SPAN>layLength<SPAN class="number token">-1</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
layLength<SPAN class="operator token">--</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>If 4 or more layers have been added to the map, the code above eliminates all of the layers,but still leaves a straggler behind, at the bottom of the layer list ... this layer, as you can see in the picture below, is turned on, but nothing shows on the map ... the layer is not real, it just shows up ... I think this may be a bug?

Thank you!