JavaScript Answers

How to fix “Uncaught TypeError: Illegal invocation” in Chrome and JavaScript?

Spread the love

To fix "Uncaught TypeError: Illegal invocation" in Chrome and JavaScript, we should make sure we’re calling a function.

For instance, we write

const obj = {
  someProperty: true,
  someMethod() {

to define the obj with the someMethod method.

Then we call it with obj.someMethod();.

It logs true since this is the obj object.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *