This:
M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
means:
if (M)
M = [M[1], M[2]];
else
M = [N, navigator.appVersion, '-?'];
More verbosely, it checks to see if "M" is non-empty, which in this case means that the useragent regex matched the actual useragent string. If it's set, then it resets "M" to a new array; effectively it just drops the zeroth element of the original "M".
If it's not set, it creates a "fake" array from the application name, the version string, and what appears to be a marker string to indicate that it's an unrecognized useragent.