# Type Error Vs Reference Error

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679494578224/9a0f2550-490f-45e4-88e4-90946325c0ec.avif align="center")

  
**Introduction**  
In this article, we will learn about the difference between Type and reference errors.  
  
**Type Error**  
The error occurs when you use something that is not intended to be used.  
example. Using a sharpener to erase something written in pencil.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679492624736/55dd1c04-6c3d-4013-8b19-e61cb04d384c.png align="center")

`Type error example1`  
Here, The variable 'a' is declared with a value of 1. The error occurred because we are calling a variable like we are calling a function.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679493516449/324c03ea-6109-406c-a830-e7814bdec6aa.png align="center")

`Type error example 2`  
Here, we are declaring a const with a value and trying to redeclare it again.  
  
**Reference error**  
It is the error, that occurs when the variable doesn't exist in the current scope or doesn't initialize (declared).  
Example. When you search for a thing that is not there.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679493880824/03338b3f-7872-4ef0-9f07-bf69c12874c0.png align="center")

`Reference error example 1`  
In this example, we are calling a variable 'b' that is not present in the code.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679494110535/eb395893-1f95-4740-8f8b-39c413b11085.png align="center")

`Reference error example 2`  
In this example, The variable 'a' is declared. But, the scope of the variable is not visible outside of curly braces{}.
