"X is not a function" in JavaScript — What It Means and How to Fix It
What the JavaScript error "X is not a function" means and how to fix it.
Published October 29, 2026
JavaScript tried to call something that is not a function: undefined, a string or an object.
What it means and why it happens
Typical causes: misspelt method names, missing imports, wrong default vs named import, or calling the result of a function that returned a value.
Read the full message: it names the file and line where the problem was detected, which is the best place to start.
What you see
run the code
TypeError: callback is not a function
Practical examples
Code that triggers it
const items = [1, 2]
items.push2(3)The fix
items.push(3)
if (typeof callback === 'function') callback()Import mistakes
import { debounce } from 'lodash' // named
import debounce from 'lodash/debounce' // defaultCommon mistakes
- Mixing default and named imports.
- Calling a property instead of a method.
- Overwriting a function with a value.
Key takeaways
- TypeError: x is not a function: JavaScript tried to call something that is not a function: undefined, a string or an object.
- Read the message and the line number first.
- Fix the cause, don't just silence the error.
FAQ
How do I know what x is?
console.log(typeof x) before calling.
How do I find which line caused TypeError: x is not a function?
The error message and stack trace show the file and line; start there and work backwards.