{"record":{"id":"d7d5edb1d0911508","repo":"alvarotrigo/fullPage.js","slug":"array-from-requires-an-array-like-object-not-nul","errorCode":null,"errorMessage":"Array.from requires an array-like object - not null or undefined","messagePattern":"Array\\.from requires an array-like object - not null or undefined","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/js/polyfills/array.from.js","lineNumber":37,"sourceCode":"            return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));\n        };\n        var maxSafeInteger = Math.pow(2, 53) - 1;\n        var toLength = function(value) {\n            var len = toInteger(value);\n            return Math.min(Math.max(len, 0), maxSafeInteger);\n        };\n\n        // The length property of the from method is 1.\n        return function from(arrayLike /*, mapFn, thisArg */) {\n            // 1. Let C be the this value.\n            var C = this;\n\n            // 2. Let items be ToObject(arrayLike).\n            var items = Object(arrayLike);\n\n            // 3. ReturnIfAbrupt(items).\n            if (arrayLike == null) {\n                throw new TypeError(\n                    'Array.from requires an array-like object - not null or undefined'\n                );\n            }\n\n            // 4. If mapfn is undefined, then let mapping be false.\n            var mapFn = arguments.length > 1 ? arguments[1] : void undefined;\n            var T;\n            if (typeof mapFn !== 'undefined') {\n                // 5. else\n                // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n                if (!isCallable(mapFn)) {\n                    throw new TypeError(\n                        'Array.from: when provided, the second argument must be a function'\n                    );\n                }\n\n                // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.\n                if (arguments.length > 2) {","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/alvarotrigo/fullPage.js/blob/49f15effa7b195def295a36f872c28153cf9fb00/src/js/polyfills/array.from.js#L19-L55","documentation":"Thrown by the Array.from polyfill (src/js/polyfills/array.from.js:37) at spec step 3, ReturnIfAbrupt after ToObject(arrayLike). When the first argument is null or undefined, ToObject fails and the polyfill throws this explicit TypeError. The native Array.from throws the same error; this code runs only where Array.from is missing.","triggerScenarios":"Calling Array.from(null), Array.from(undefined), or Array.from(value) where value is null/undefined at runtime, such as a missing DOM lookup (document.querySelector('#x') returns null) or a defaulted-out optional argument passed straight through.","commonSituations":"Converting a querySelector/All result or a JSON.parse result (which can be null) into an array without a null guard; calling Array.from(config.list) when config.list is absent; older browsers where the polyfill is the active code path.","solutions":["Guard the input before conversion: if (value) { arr = Array.from(value); }.","Default to an empty array-like when the source may be missing: Array.from(value || []).","Fix the upstream lookup that returned null (e.g., the missing selector or unparseable JSON) rather than masking the symptom.","If accepting user/config input, validate it is array-like (has a .length) before passing it in."],"exampleFix":"// before\nconst nodes = Array.from(document.querySelector('.item'));\n// querySelector returns null -> Array.from requires an array-like object\n\n// after\nconst node = document.querySelector('.item');\nconst nodes = node ? Array.from([node]) : [];","handlingStrategy":"validation","validationCode":"function toArray(value) {\n  if (value == null) return [];\n  if (Array.isArray(value)) return value.slice();\n  if (typeof value.length === 'number') return Array.prototype.slice.call(value);\n  return Array.from(value);\n}","typeGuard":"function isArrayLike(value) {\n  return value != null && typeof value !== 'function' && typeof value.length === 'number' && value.length >= 0;\n}","tryCatchPattern":null,"preventionTips":["Always null-check DOM/query results before converting: const node = el || [];.","Default optional inputs: Array.from(maybeList || []).","Validate the source has a numeric .length (array-like contract) before calling Array.from."],"tags":["polyfill","array","null-check","es2015","dom"],"backgroundTag":null,"analyzedSha":"49f15effa7b195def295a36f872c28153cf9fb00","analyzedAt":"2026-08-13T04:33:34.972Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}