JavaScript Error

Fix: Uncaught TypeError: x is not a function

By Samrat•Last updated: Nov 2026

Exact message

Uncaught TypeError: myFunc is not a function

Quick answer

This error means you are trying to call something as a function that is not actually a function. It could be a string, object, or undefined. Check your imports and variable names.

🛠️ Fix it right here with AI Code Explainer

Edit the traceback below if needed, then let our AI suggest a fix without leaving this page.

AI suggestions can be wrong. Review and test before applying.

Why this error happens

Common causes include: misspelling a built-in method (e.g., 'toUppercase' instead of 'toUpperCase'), importing a default export incorrectly, or trying to call an object as a function.

Example: Wrong vs Right

Wrong

const str = "hello";
str.toUppercase();
// Uncaught TypeError: str.toUppercase is not a function

Right

const str = "hello";
str.toUpperCase();

// Or check the type before calling
if (typeof myFunc === 'function') {
  myFunc();
}

How to fix it (step by step)

  1. Check the exact spelling and capitalization of the function name (JS is case-sensitive)
  2. Use console.log(typeof myFunc) to see what type it actually is
  3. If it's an import, verify it's a named export vs default export
  4. If it's an array method (e.g., .map), ensure the variable is actually an array

Frequently asked questions

Why is my imported function undefined?

You might be using the wrong import syntax. For default exports use import func from './file', for named exports use import { func } from './file'.

Does this happen with callbacks?

Yes, if you pass a variable that is undefined or not a function to an event listener or array method.

Related Search Terms

is not a functionuncaught typeerror not a functionarray map is not a functionimport is not a function

Related JS errors

Need to fix JS code not just errors?

Use the free to paste any JS snippet and get a line-by-line explanation.

Want an AI with memory for your project?

MonsterX AI remembers your codebase across chats.