The browser (or Node) met a name it has no record of: not declared with var/let/const, not a function, not a loaded library. The console tells you the file and line — start there, because the cause is one of four things almost every time.
userName vs username are different names in JavaScript too.let or const declared inside a block (an if, a loop, a function) doesn’t exist outside it. Move the declaration out, or return/pass the value properly.A quick scope probe: run `typeof x` in the console — "undefined" from typeof (without throwing) confirms the name truly doesn’t exist in scope, versus existing but holding the value undefined (a different bug: declared, never given a value).
ReferenceError vs “x is not a function”? ReferenceError: the name doesn’t exist at all. “Not a function”: the name exists but holds something that isn’t callable — a different hunt.
Why does it work in one browser and not another? Usually script loading: a CDN script blocked by one browser’s tracking protection or an ad-blocker means the library name never arrives. The Network tab shows it.