Whenever you deal with operational layers, you probably have to know the "layer id", and for some reasons, the developer have to keep track and make sure that the layer id does not changed with respect to the web map.
I believe, the web map should follow a standard when assigning id(s) to the operational layers so that developer's code still running even the layer deleted from the web map and added again with a new layer id.
If you have this layer id "WORLD_BORDERS_9242" and you use it in the code or in config.json. If you remove the layer from the web map and added it again, it will have different layer id (maybe "WORLD_BORDERS_627" ), and you must to modify the code/config.
If the suffix "9242" has a meaning, we can design our own pattern to expect the layer id.