When I try to execute the following code snippet:
function isRegExp(value) {
return toString.call(value) === '[object RegExp]';
}
in Internet Explorer versions 11 and below (tested on 11 and 9), I encounter a
TypeError: Invalid calling object
. This piece of code runs without issues in newer browser versions and other browsers.
Initially, I find it puzzling. The function is identical to the one used in AngularJS, which claims compatibility with IE 9+. How come when I use the exact same function, it throws an error (thus causing my calling function to fail), especially since I assume they would have tested it thoroughly already?
Moreover, I am intrigued about what might be triggering this problem. This function can accept any value in JavaScript, but it seems to only break with certain inputs (it doesn't throw errors when provided with a simple array, however, it struggles with arrays containing objects or arrays within objects...).