Some code of making a condition to the IE browser?

 if (navigator.appName == "Microsoft Internet Explorer") {
begin = navigator.userAgent.indexOf("MSIE ") +
"MSIE ".length;
if(navigator.userAgent.indexOf(";", begin) > 0) {
end = navigator.userAgent.indexOf(";", begin);
} else {
end = navigator.userAgent.indexOf(")", begin)
+ 2;
document.getElementById("targetDiv").innerHTML =
"You are using Internet Explorer " +
navigator.userAgent.substring(begin, end);

i don’t know why there added an else part? what’s the meaning and effect of it? thank you,

It’s to allow for a couple of different variations in how the userAgent text is formatted.

Please do not use such browser sniffing techniques though. They are incredibly brittle because browsers and their capabilities change over time, so instead use object detection instead.

For example:

if ( !Array.prototype.forEach ) {