I have encountered an issue with my browser sniffer code that uses the function detect.js. Interestingly, the code works perfectly fine when it is not integrated into my project. However, as soon as I compile the JavaScript and include it in app.js, I encounter an error in the console right at the beginning of the code snippet below, where the browser version detection takes place.
Uncaught ReferenceError: forEach is not defined.
// Each Utility
var each = forEach = function (obj, iterator, context) {
if (obj == null) return;
if (nativeForEach && obj.forEach === nativeForEach) {
obj.forEach(iterator, context);
} else if (obj.length === +obj.length) {
for (var i = 0, l = obj.length; i < l; i++) {
iterator.call(context, obj[i], i, obj);
}
} else {
for (var key in obj) {
if (_.has(obj, key)) {
iterator.call(context, obj[key], key, obj);
}
}
}
};
It appears that the act of compiling the JavaScript may be causing this issue. Any suggestions on how to resolve it?