Reference Error Vs Type Error
Reference error
In a case where a variable reference can't be found or hasn't been declared, then a Reference error occurs. ( buying a gift on a valentine but later you realize you don't have a girlfriend. It's a reference error.)
console.log( girlfriend )// reference error : girlfriend is not defined.
//correct way
const girlfriend = 'angel priya'
console.log(girlfriend)// angel priya
Type error
An error occurs when a value is used outside the scope of its data type. ( try to eat soup with a fork. you can't. it's a type error).
var num = 13;
num.toUpperCase();//Uncaught TypeError: num.toUpperCase is not a function ( it's not possible to change a number into uppercase)
//correct way
var num = 13;
num.toString().toUpperCase();// '1'
Conclusions
whenever we try to access the value of a variable or function or object before defining it, we get a reference error.
whenever we try to do anything which is logically not possible like trying to convert a number into uppercase, we get a type error.