JavaScript TypeError: is not a function
A plain-words explanation of this JavaScript message: what it means, the usual causes, and the steps that fix it.
The messageUncaught TypeError: numbers.push2 is not a function
Make the error yourself
Run in Google Chrome 157.0.8103.51. This is the smallest example we could find that shows it.
JavaScript (in a script tag)
const numbers = [1, 2];
numbers.push2(3);Browser console (the real message)
TypeError: numbers.push2 is not a functionWhy it happens
You wrote a call (something(...)) but what stands before the brackets is not a function. The message shows the exact expression, here numbers.push2, which does not exist, so it is undefined. Other typical causes: a typo in a method name, calling a method on the wrong type ("text".push(...)), a variable that holds a number or a string where you expected a function, a callback that you forgot to pass, or a library that has not finished loading.
How to fix it
- Read the expression in the message. Log it:
console.log(typeof numbers.push2)printsundefined. - Check the spelling. Methods are case sensitive (
toUpperCase, nottouppercase). - Check the type of the value:
console.log(typeof value); arrays havepush, strings do not. - If you pass a function to another function, pass the function itself without brackets:
setTimeout(run, 100), notsetTimeout(run(), 100).
The corrected version
JavaScript (in a script tag)
const numbers = [1, 2];
numbers.push(3);
console.log(numbers);Browser console (the corrected version)
[1, 2, 3]How to avoid it
Use an editor that completes method names. When a method name exists in one object but not another, read the documentation for that exact object.
Questions
Why does it say "is not a function" for something I defined?
Perhaps the name was later replaced by another value, or it is defined after the call because const and let are not available before their line.
This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.