Type error vs Reference error 😛

Type error vs Reference error 😛

·

2 min read

Errors are one of my favorite topics because I always get them.

Type Error:

" can not read properties of undefined "

Yes, it's always there whenever you try to access a variable or property which is undefined.

So what is that and why you are getting it?

If you are trying to convert a number to an uppercase character. As toUpperCase() is a function to convert a string to uppercase characters, it will throw an error for following code structure.

We can not convert the number to uppercase but we can convert the string here

A TypeError occurs when the variable exists, but the operation you're trying to perform is not appropriate for the type of value it contains.

Reference Error :

"Uncaught Reference error: something is not defined "

Here here,
suppose I am trying to access a variable that does not exist 😶😶.

here I am trying to access um which doesn't exist at all.

A ReferenceError occurs when you try to use a variable that doesn't exist at all.

Summary ✨ :

A reference error is thrown when there is no reference and a Type error is thrown when we try to do something which is not appropriate for that object.

will try to write in a more simplified and better way 🤠 thanks for reading🥰.

Â