How to know the object's type? Javascript

29 Views Asked by At

i have that print on my console.

enter image description here

enter image description here

I print this when my error function is called

export function handleRequestError(error) {
  console.log(error);
}

When I do, error.cancel, it comes undefined. Would I be able to do some verification of this type? If cancel comes, I do something like that

    export function handleRequestError(error) {
          console.log(error);
          if(error['Cancel'] === undefined) return //doesnt work
   }

How do I check that "Cancel"?

1

There are 1 best solutions below

0
Samathingamajig On

In the prototype, you can see that the property __CANCEL__ is set to true.

Do this:

export function handleRequestError(error) {
  console.log(error);
  if(error['__CANCEL__'] === undefined) return;
}