{"record":{"id":"3f3843d75b102d0f","repo":"ssssssss-team/spider-flow","slug":"g-is-not-a-function","errorCode":null,"errorMessage":"\" + g + \" is not a function","messagePattern":"\" \\+ g \\+ \" is not a function","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"spider-flow-web/src/main/resources/static/js/layui/extends/formSelects-v4.js","lineNumber":208,"sourceCode":"\t\t\t\t    c,\n\t\t\t\t    e = Object(this),\n\t\t\t\t    f = e.length >>> 0;if (h) {\n\t\t\t\t\tb = h;\n\t\t\t\t}a = new Array(f);c = 0;while (c < f) {\n\t\t\t\t\tvar d, g;if (c in e) {\n\t\t\t\t\t\td = e[c];g = i.call(b, d, c, e);a[c] = g;\n\t\t\t\t\t}c++;\n\t\t\t\t}return a;\n\t\t\t};\n\t\t};\n\n\t\t//拓展Array foreach方法\n\t\tif (!Array.prototype.forEach) {\n\t\t\tArray.prototype.forEach = function forEach(g, b) {\n\t\t\t\tvar d, c;if (this == null) {\n\t\t\t\t\tthrow new TypeError(\"this is null or not defined\");\n\t\t\t\t}var f = Object(this);var a = f.length >>> 0;if (typeof g !== \"function\") {\n\t\t\t\t\tthrow new TypeError(g + \" is not a function\");\n\t\t\t\t}if (arguments.length > 1) {\n\t\t\t\t\td = b;\n\t\t\t\t}c = 0;while (c < a) {\n\t\t\t\t\tvar e;if (c in f) {\n\t\t\t\t\t\te = f[c];g.call(d, e, c, f);\n\t\t\t\t\t}c++;\n\t\t\t\t}\n\t\t\t};\n\t\t};\n\n\t\t//拓展Array filter方法\n\t\tif (!Array.prototype.filter) {\n\t\t\tArray.prototype.filter = function (b) {\n\t\t\t\tif (this === void 0 || this === null) {\n\t\t\t\t\tthrow new TypeError();\n\t\t\t\t}var f = Object(this);var a = f.length >>> 0;if (typeof b !== \"function\") {\n\t\t\t\t\tthrow new TypeError();\n\t\t\t\t}var e = [];var d = arguments[1];for (var c = 0; c < a; c++) {","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/ssssssss-team/spider-flow/blob/c799cca99c7d064673dc79e6ef06a08bbc0e292d/spider-flow-web/src/main/resources/static/js/layui/extends/formSelects-v4.js#L190-L226","documentation":"The same Array.prototype.forEach polyfill in formSelects-v4.js validates its first argument. If the callback `g` is not a function it throws TypeError(g + ' is not a function'), mirroring the ES5 specification. The odd message text with escaped quotes is an artifact of how the error was captured/escaped.","triggerScenarios":"Passing a non-function (undefined, null, string, object) as the first argument to forEach, typically because the callback variable is undefined due to a typo, failed lookup, or wrong argument order.","commonSituations":"Calling `arr.forEach(arr[i])` style mistakes, callbacks returned from optional APIs that came back undefined, refactors that renamed the callback function but not all call sites, in environments relying on the polyfill (old IE).","solutions":["Ensure the first argument to forEach is a function; check the callback variable is defined and spelled correctly.","Guard: `if (typeof cb === 'function') arr.forEach(cb)`.","Fix argument order if values were swapped at the call site."],"exampleFix":"// before\nlist.forEach(callbackName); // callbackName is undefined\n// after\nif (typeof callbackName === 'function') { list.forEach(callbackName); }","handlingStrategy":"validation","validationCode":"if (typeof callback !== 'function') { throw new TypeError('forEach callback must be a function, got: ' + callback); } items.forEach(callback);","typeGuard":"function isFunction(v) { return typeof v === 'function'; }","tryCatchPattern":"try {\n  items.forEach(callback);\n} catch (e) {\n  if (e instanceof TypeError && /is not a function/.test(e.message)) { callback = defaultCallback; items.forEach(callback); }\n  else throw e;\n}","preventionTips":["Verify the callback reference is defined at the call site (typos rename risk).","Check argument order when wrapping forEach-like calls.","Use linters (no-undef, no-unused-vars) to catch undefined callback references."],"tags":["javascript","polyfill","foreach","typeerror"],"backgroundTag":"invalid-argument-value","analyzedSha":"c799cca99c7d064673dc79e6ef06a08bbc0e292d","analyzedAt":"2026-09-08T13:47:08.225Z","contentChangedAt":"2026-09-08T13:47:08.225Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}